feat(cmd/joj3): create log dir if not exists
All checks were successful
submodules sync / sync (push) Successful in 57s
build / build (push) Successful in 2m44s
build / trigger-build-image (push) Successful in 11s

This commit is contained in:
张泊明518370910136 2025-06-25 22:50:56 -04:00
parent 498fcf2cdf
commit aa377c1046
GPG Key ID: D47306D7062CDA9D

View File

@ -6,6 +6,7 @@ import (
"io"
"log/slog"
"os"
"path/filepath"
"github.com/joint-online-judge/JOJ3/cmd/joj3/conf"
"github.com/joint-online-judge/JOJ3/cmd/joj3/env"
@ -111,6 +112,10 @@ func setupSlog(conf *conf.Conf) error {
attrs := newSlogAttrs(conf.ActorCsvPath)
handlers := []slog.Handler{}
if logPath != "" {
logDir := filepath.Dir(logPath)
if err := os.MkdirAll(logDir, 0o750); err != nil {
return err
}
// Text file handler for debug logs
debugTextFile, err := os.OpenFile(logPath,
os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o640)