From 35d7f62fbce59ddb44a827336878366974c18cf7 Mon Sep 17 00:00:00 2001 From: Shyunn Date: Wed, 18 Dec 2024 13:07:41 +0800 Subject: [PATCH] fix: Use CallerFlagMode type alias instead of uint8 (#155) Signed-off-by: Shyunn Co-authored-by: Shyunn --- common.go | 5 ++++- logger.go | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/common.go b/common.go index c7f0c01..3be9c9c 100644 --- a/common.go +++ b/common.go @@ -94,12 +94,15 @@ func (fn ClockFn) Now() time.Time { return fn() } +// CallerFlagMode Defines the Caller backtrace information mode. +type CallerFlagMode = uint8 + // NOTICE: you must set `Logger.ReportCaller=true` for reporting caller. // then config the Logger.CallerFlag by follow flags. const ( // CallerFlagFnlFcn report short func name with filename and with line. // eg: "logger_test.go:48,TestLogger_ReportCaller" - CallerFlagFnlFcn uint8 = iota + CallerFlagFnlFcn CallerFlagMode = iota // CallerFlagFull full func name with filename and with line. // eg: "github.com/gookit/slog_test.TestLogger_ReportCaller(),logger_test.go:48" CallerFlagFull diff --git a/logger.go b/logger.go index 04a10b2..e456dd1 100644 --- a/logger.go +++ b/logger.go @@ -43,7 +43,8 @@ type Logger struct { // ReportCaller on write log record ReportCaller bool CallerSkip int - CallerFlag uint8 + // CallerFlag used to set caller traceback information in different modes + CallerFlag CallerFlagMode // BackupArgs backup log input args to Record.Args BackupArgs bool // TimeClock custom time clock, timezone