feat: support one or more log file (#1400)
Co-authored-by: Laisky.Cai <github@laisky.com>
This commit is contained in:
parent
274fcf3d76
commit
c4fe57c165
@ -145,6 +145,9 @@ var InitialRootToken = os.Getenv("INITIAL_ROOT_TOKEN")
|
||||
|
||||
var GeminiVersion = env.String("GEMINI_VERSION", "v1")
|
||||
|
||||
|
||||
var OnlyOneLogFile = env.Bool("ONLY_ONE_LOG_FILE", false)
|
||||
|
||||
var RelayProxy = env.String("RELAY_PROXY", "")
|
||||
var UserContentRequestProxy = env.String("USER_CONTENT_REQUEST_PROXY", "")
|
||||
var UserContentRequestTimeout = env.Int("USER_CONTENT_REQUEST_TIMEOUT", 30)
|
||||
|
@ -27,7 +27,12 @@ var setupLogOnce sync.Once
|
||||
func SetupLogger() {
|
||||
setupLogOnce.Do(func() {
|
||||
if LogDir != "" {
|
||||
logPath := filepath.Join(LogDir, fmt.Sprintf("oneapi-%s.log", time.Now().Format("20060102")))
|
||||
var logPath string
|
||||
if config.OnlyOneLogFile {
|
||||
logPath = filepath.Join(LogDir, "oneapi.log")
|
||||
} else {
|
||||
logPath = filepath.Join(LogDir, fmt.Sprintf("oneapi-%s.log", time.Now().Format("20060102")))
|
||||
}
|
||||
fd, err := os.OpenFile(logPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
log.Fatal("failed to open log file")
|
||||
|
Loading…
Reference in New Issue
Block a user