-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refact(zap): custom lumberjack with sync.WaitGroup
- Loading branch information
Matrix-X
committed
Jun 22, 2024
1 parent
dce1335
commit 768fb31
Showing
7 changed files
with
1,477 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// +build !linux | ||
|
||
package lumberjack | ||
|
||
import ( | ||
"os" | ||
) | ||
|
||
func chown(_ string, _ os.FileInfo) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package lumberjack | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
) | ||
|
||
// osChown is a var so we can mock it out during tests. | ||
var osChown = os.Chown | ||
|
||
func chown(name string, info os.FileInfo) error { | ||
f, err := os.OpenFile(name, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, info.Mode()) | ||
if err != nil { | ||
return err | ||
} | ||
f.Close() | ||
stat := info.Sys().(*syscall.Stat_t) | ||
return osChown(name, int(stat.Uid), int(stat.Gid)) | ||
} |
Oops, something went wrong.