mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 14:50:55 +03:00
refactoring: add common package
The common package defines the interfaces that a protocol must implement and contain code that can be shared among supported protocols. This way should be easier to support new protocols
This commit is contained in:
@@ -14,7 +14,6 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sync"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
lumberjack "gopkg.in/natefinch/lumberjack.v2"
|
||||
@@ -60,9 +59,9 @@ func InitLogger(logFilePath string, logMaxSize int, logMaxBackups int, logMaxAge
|
||||
logger = zerolog.New(rollingLogger)
|
||||
EnableConsoleLogger(level)
|
||||
} else {
|
||||
logger = zerolog.New(logSyncWrapper{
|
||||
logger = zerolog.New(&logSyncWrapper{
|
||||
output: os.Stdout,
|
||||
lock: new(sync.Mutex)})
|
||||
})
|
||||
consoleLogger = zerolog.Nop()
|
||||
}
|
||||
logger = logger.Level(level)
|
||||
|
||||
@@ -6,12 +6,12 @@ import (
|
||||
)
|
||||
|
||||
type logSyncWrapper struct {
|
||||
sync.Mutex
|
||||
output *os.File
|
||||
lock *sync.Mutex
|
||||
}
|
||||
|
||||
func (l logSyncWrapper) Write(b []byte) (n int, err error) {
|
||||
l.lock.Lock()
|
||||
defer l.lock.Unlock()
|
||||
func (l *logSyncWrapper) Write(b []byte) (n int, err error) {
|
||||
l.Lock()
|
||||
defer l.Unlock()
|
||||
return l.output.Write(b)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user