mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 06:40:54 +03:00
log file: if the path is not absolute make it relative to config dir
Also refuse to join invalid file name such as "." Fixes #85
This commit is contained in:
@@ -11,6 +11,7 @@ package logger
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sync"
|
||||
|
||||
@@ -46,7 +47,7 @@ func GetLogger() *zerolog.Logger {
|
||||
// InitLogger configures the logger using the given parameters
|
||||
func InitLogger(logFilePath string, logMaxSize int, logMaxBackups int, logMaxAge int, logCompress bool, level zerolog.Level) {
|
||||
zerolog.TimeFieldFormat = dateFormat
|
||||
if len(logFilePath) > 0 {
|
||||
if len(logFilePath) > 0 && filepath.Clean(logFilePath) != "." {
|
||||
logger = zerolog.New(&lumberjack.Logger{
|
||||
Filename: logFilePath,
|
||||
MaxSize: logMaxSize,
|
||||
|
||||
Reference in New Issue
Block a user