Skip to content

Commit

Permalink
Merge pull request #109 from ArtisanCloud/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Matrix-X authored Jun 22, 2024
2 parents c18c3cf + f21f46b commit 1039b54
Show file tree
Hide file tree
Showing 7 changed files with 1,474 additions and 1 deletion.
2 changes: 1 addition & 1 deletion logger/drivers/zap/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package zap

import (
"github.com/ArtisanCloud/PowerLibs/v3/logger/contract"
lumberjack "github.com/ArtisanCloud/PowerLibs/v3/logger/lib"
"github.com/ArtisanCloud/PowerLibs/v3/object"
os2 "github.com/ArtisanCloud/PowerLibs/v3/os"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"gopkg.in/natefinch/lumberjack.v2"
"os"
"time"
)
Expand Down
11 changes: 11 additions & 0 deletions logger/lib/chown.go
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
}
19 changes: 19 additions & 0 deletions logger/lib/chown_linux.go
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))
}
Loading

0 comments on commit 1039b54

Please sign in to comment.