feat: support one or more log file
This commit is contained in:
parent
2720e1a358
commit
420c6a8754
@ -144,3 +144,5 @@ var MetricFailChanSize = env.Int("METRIC_FAIL_CHAN_SIZE", 128)
|
||||
var InitialRootToken = os.Getenv("INITIAL_ROOT_TOKEN")
|
||||
|
||||
var GeminiVersion = env.String("GEMINI_VERSION", "v1")
|
||||
|
||||
var OnlyOneLogFile = env.Bool("ONLY_ONE_LOG_FILE", false)
|
@ -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