diff --git a/main.go b/main.go index 14108fe..88e7a8b 100644 --- a/main.go +++ b/main.go @@ -106,6 +106,7 @@ func main() { logger.Setup(&logger.Logger{ Level: logger.InfoLevel, Prefix: "quickgo", + OutputTime: true, WrapPrefix: quickgo.ColoredLogWrapper, }) diff --git a/quickgo/logger/logger.go b/quickgo/logger/logger.go index 1b794ff..8a2148f 100644 --- a/quickgo/logger/logger.go +++ b/quickgo/logger/logger.go @@ -62,6 +62,9 @@ type Logger struct { // Suffix is the suffix for each log message. Suffix string + // Display a timestamp alongside the log message. + OutputTime bool + // Outputs for the log messages. OutputDebug io.Writer OutputInfo io.Writer @@ -233,10 +236,13 @@ func (l *Logger) writePrefix(level LogLevel, w io.Writer) { } _, _ = b.Write([]byte(level.String())) - _, _ = b.Write([]byte(" / ")) - var t = time.Now().Format("2006-01-02 15:04:05") - _, _ = b.Write([]byte(t)) + if l.OutputTime { + _, _ = b.Write([]byte(" / ")) + var t = time.Now().Format("2006-01-02 15:04:05") + _, _ = b.Write([]byte(t)) + } + _, _ = b.Write([]byte("]: ")) var prefix = b.String()