mirror of
https://github.com/simon-ding/polaris.git
synced 2026-03-16 07:00:52 +08:00
feat: log to console in dev
This commit is contained in:
@@ -25,7 +25,7 @@ COPY --from=flutter /app/build/web ./ui/build/web/
|
||||
RUN CGO_ENABLED=1 go build -o polaris -ldflags="-X polaris/db.Version=$(git describe --tags --long)" ./cmd/
|
||||
|
||||
FROM debian:12
|
||||
ENV TZ="Asia/Shanghai"
|
||||
ENV TZ="Asia/Shanghai" GIN_MODE=release
|
||||
|
||||
WORKDIR /app
|
||||
RUN apt-get update && apt-get -y install ca-certificates
|
||||
|
||||
17
log/log.go
17
log/log.go
@@ -1,6 +1,7 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
@@ -18,12 +19,16 @@ func init() {
|
||||
atom = zap.NewAtomicLevel()
|
||||
atom.SetLevel(zap.DebugLevel)
|
||||
|
||||
w := zapcore.AddSync(&lumberjack.Logger{
|
||||
Filename: filepath.Join(dataPath, "logs", "polaris.log"),
|
||||
MaxSize: 50, // megabytes
|
||||
MaxBackups: 3,
|
||||
MaxAge: 30, // days
|
||||
})
|
||||
w := zapcore.Lock(os.Stdout)
|
||||
if os.Getenv("GIN_MODE") == "release" {
|
||||
w = zapcore.AddSync(&lumberjack.Logger{
|
||||
Filename: filepath.Join(dataPath, "logs", "polaris.log"),
|
||||
MaxSize: 50, // megabytes
|
||||
MaxBackups: 3,
|
||||
MaxAge: 30, // days
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
consoleEncoder := zapcore.NewConsoleEncoder(zap.NewDevelopmentEncoderConfig())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user