Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
02fed6e55f | |||
1712042f64 | |||
f8a72d3579 | |||
65cbfe78c3 | |||
6d60f7f813 |
30
colors.go
30
colors.go
@@ -1,4 +1,4 @@
|
|||||||
package main
|
package cylogger
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -19,6 +19,10 @@ const (
|
|||||||
Cyan = "\033[0;36m" // Cyan
|
Cyan = "\033[0;36m" // Cyan
|
||||||
White = "\033[0;37m" // White
|
White = "\033[0;37m" // White
|
||||||
Orange = "\033[38;5;208m" // Orange
|
Orange = "\033[38;5;208m" // Orange
|
||||||
|
Pink = "\033[38;5;205m" // Pink
|
||||||
|
Brown = "\033[38;5;130m" // Brown
|
||||||
|
Gray = "\033[38;5;240m" // Gray
|
||||||
|
Magenta = "\033[38;5;201m" // Magenta
|
||||||
|
|
||||||
// Bold
|
// Bold
|
||||||
BBlack = "\033[1;30m" // Black
|
BBlack = "\033[1;30m" // Black
|
||||||
@@ -30,6 +34,10 @@ const (
|
|||||||
BCyan = "\033[1;36m" // Cyan
|
BCyan = "\033[1;36m" // Cyan
|
||||||
BWhite = "\033[1;37m" // White
|
BWhite = "\033[1;37m" // White
|
||||||
BOrange = "\033[1;38;5;208m" // Bold Orange
|
BOrange = "\033[1;38;5;208m" // Bold Orange
|
||||||
|
BPink = "\033[1;38;5;205m" // Bold Pink
|
||||||
|
BBrown = "\033[1;38;5;130m" // Bold Brown
|
||||||
|
BGray = "\033[1;38;5;240m" // Bold Gray
|
||||||
|
BMagenta = "\033[1;38;5;201m" // Bold Magenta
|
||||||
|
|
||||||
// Underline
|
// Underline
|
||||||
UBlack = "\033[4;30m" // Black
|
UBlack = "\033[4;30m" // Black
|
||||||
@@ -41,6 +49,10 @@ const (
|
|||||||
UCyan = "\033[4;36m" // Cyan
|
UCyan = "\033[4;36m" // Cyan
|
||||||
UWhite = "\033[4;37m" // White
|
UWhite = "\033[4;37m" // White
|
||||||
UOrange = "\033[4;38;5;208m" // Underline Orange
|
UOrange = "\033[4;38;5;208m" // Underline Orange
|
||||||
|
UPink = "\033[4;38;5;205m" // Underline Pink
|
||||||
|
UBrown = "\033[4;38;5;130m" // Underline Brown
|
||||||
|
UGray = "\033[4;38;5;240m" // Underline Gray
|
||||||
|
UMagenta = "\033[4;38;5;201m" // Underline Magenta
|
||||||
|
|
||||||
// Background
|
// Background
|
||||||
On_Black = "\033[40m" // Black
|
On_Black = "\033[40m" // Black
|
||||||
@@ -52,6 +64,10 @@ const (
|
|||||||
On_Cyan = "\033[46m" // Cyan
|
On_Cyan = "\033[46m" // Cyan
|
||||||
On_White = "\033[47m" // White
|
On_White = "\033[47m" // White
|
||||||
On_Orange = "\033[48;5;208m" // Orange Background
|
On_Orange = "\033[48;5;208m" // Orange Background
|
||||||
|
On_Pink = "\033[48;5;205m" // Pink Background
|
||||||
|
On_Brown = "\033[48;5;130m" // Brown Background
|
||||||
|
On_Gray = "\033[48;5;240m" // Gray Background
|
||||||
|
On_Magenta = "\033[48;5;201m" // Magenta Background
|
||||||
|
|
||||||
// High Intensty
|
// High Intensty
|
||||||
IBlack = "\033[0;90m" // Black
|
IBlack = "\033[0;90m" // Black
|
||||||
@@ -63,6 +79,10 @@ const (
|
|||||||
ICyan = "\033[0;96m" // Cyan
|
ICyan = "\033[0;96m" // Cyan
|
||||||
IWhite = "\033[0;97m" // White
|
IWhite = "\033[0;97m" // White
|
||||||
IOrange = "\033[0;38;5;208m" // Intense Orange
|
IOrange = "\033[0;38;5;208m" // Intense Orange
|
||||||
|
IPink = "\033[0;38;5;205m" // Intense Pink
|
||||||
|
IBrown = "\033[0;38;5;130m" // Intense Brown
|
||||||
|
IGray = "\033[0;38;5;240m" // Intense Gray
|
||||||
|
IMagenta = "\033[0;38;5;201m" // Intense Magenta
|
||||||
|
|
||||||
// Bold High Intensty
|
// Bold High Intensty
|
||||||
BIBlack = "\033[1;90m" // Black
|
BIBlack = "\033[1;90m" // Black
|
||||||
@@ -74,6 +94,10 @@ const (
|
|||||||
BICyan = "\033[1;96m" // Cyan
|
BICyan = "\033[1;96m" // Cyan
|
||||||
BIWhite = "\033[1;97m" // White
|
BIWhite = "\033[1;97m" // White
|
||||||
BIOrange = "\033[1;38;5;208m" // Bold Intense Orange
|
BIOrange = "\033[1;38;5;208m" // Bold Intense Orange
|
||||||
|
BIPink = "\033[1;38;5;205m" // Bold Intense Pink
|
||||||
|
BIBrown = "\033[1;38;5;130m" // Bold Intense Brown
|
||||||
|
BIGray = "\033[1;38;5;240m" // Bold Intense Gray
|
||||||
|
BIMagenta = "\033[1;38;5;201m" // Bold Intense Magenta
|
||||||
|
|
||||||
// High Intensty backgrounds
|
// High Intensty backgrounds
|
||||||
On_IBlack = "\033[0;100m" // Black
|
On_IBlack = "\033[0;100m" // Black
|
||||||
@@ -85,6 +109,10 @@ const (
|
|||||||
On_ICyan = "\033[0;106m" // Cyan
|
On_ICyan = "\033[0;106m" // Cyan
|
||||||
On_IWhite = "\033[0;107m" // White
|
On_IWhite = "\033[0;107m" // White
|
||||||
On_IOrange = "\033[0;48;5;208m" // Intense Orange Background
|
On_IOrange = "\033[0;48;5;208m" // Intense Orange Background
|
||||||
|
On_IPink = "\033[0;48;5;205m" // Intense Pink Background
|
||||||
|
On_IBrown = "\033[0;48;5;130m" // Intense Brown Background
|
||||||
|
On_IGray = "\033[0;48;5;240m" // Intense Gray Background
|
||||||
|
On_IMagenta = "\033[0;48;5;201m" // Intense Magenta Background
|
||||||
)
|
)
|
||||||
|
|
||||||
// The acceptable range is [16, 231] but here we remove some very dark colors
|
// The acceptable range is [16, 231] but here we remove some very dark colors
|
||||||
|
12
go.mod
12
go.mod
@@ -1,3 +1,13 @@
|
|||||||
module git.site.quack-lab.dev/dave/cylogger
|
module git.site.quack-lab.dev/dave/cylogger
|
||||||
|
|
||||||
go 1.24.2
|
go 1.23
|
||||||
|
|
||||||
|
require github.com/hexops/valast v1.5.0
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/google/go-cmp v0.5.9 // indirect
|
||||||
|
golang.org/x/mod v0.7.0 // indirect
|
||||||
|
golang.org/x/sys v0.3.0 // indirect
|
||||||
|
golang.org/x/tools v0.4.0 // indirect
|
||||||
|
mvdan.cc/gofumpt v0.4.0 // indirect
|
||||||
|
)
|
||||||
|
26
go.sum
Normal file
26
go.sum
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
|
||||||
|
github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
|
||||||
|
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||||
|
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
|
github.com/hexops/autogold v0.8.1 h1:wvyd/bAJ+Dy+DcE09BoLk6r4Fa5R5W+O+GUzmR985WM=
|
||||||
|
github.com/hexops/autogold v0.8.1/go.mod h1:97HLDXyG23akzAoRYJh/2OBs3kd80eHyKPvZw0S5ZBY=
|
||||||
|
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
|
||||||
|
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
|
||||||
|
github.com/hexops/valast v1.5.0 h1:FBTuvVi0wjTngtXJRZXMbkN/Dn6DgsUsBwch2DUJU8Y=
|
||||||
|
github.com/hexops/valast v1.5.0/go.mod h1:Jcy1pNH7LNraVaAZDLyv21hHg2WBv9Nf9FL6fGxU7o4=
|
||||||
|
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||||
|
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||||
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
|
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||||
|
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||||
|
golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
|
||||||
|
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
|
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||||
|
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
|
||||||
|
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/tools v0.4.0 h1:7mTAgkunk3fr4GAloyyCasadO6h9zSsQZbwvcaIciV4=
|
||||||
|
golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ=
|
||||||
|
mvdan.cc/gofumpt v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM=
|
||||||
|
mvdan.cc/gofumpt v0.4.0/go.mod h1:PljLOHDeZqgS8opHRKLzp2It2VBuSdteAgqUfzMTxlQ=
|
131
main.go
131
main.go
@@ -1,5 +1,4 @@
|
|||||||
// package cylogger
|
package cylogger
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@@ -14,6 +13,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/hexops/valast"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Enable turning colors on and off maybe even per stream?
|
// TODO: Enable turning colors on and off maybe even per stream?
|
||||||
@@ -34,6 +35,8 @@ const (
|
|||||||
LevelDebug
|
LevelDebug
|
||||||
// LevelTrace is for very detailed tracing information
|
// LevelTrace is for very detailed tracing information
|
||||||
LevelTrace
|
LevelTrace
|
||||||
|
// LevelDump is for dumping objects to console for regressive tests
|
||||||
|
LevelDump
|
||||||
// LevelLua is specifically for output from Lua scripts
|
// LevelLua is specifically for output from Lua scripts
|
||||||
LevelLua
|
LevelLua
|
||||||
LevelPrefix
|
LevelPrefix
|
||||||
@@ -76,20 +79,26 @@ var levelStyles = map[LogLevel]LevelStyle{
|
|||||||
Tag: "TRACE",
|
Tag: "TRACE",
|
||||||
TagColor: BPurple, // Bold Purple
|
TagColor: BPurple, // Bold Purple
|
||||||
},
|
},
|
||||||
|
LevelDump: {
|
||||||
|
Tag: "DUMP",
|
||||||
|
TagColor: BIMagenta, // Bold Intense Magenta
|
||||||
|
TagBackgroundColor: On_White, // White background
|
||||||
|
MessageColor: IMagenta, // White text
|
||||||
|
},
|
||||||
LevelLua: {
|
LevelLua: {
|
||||||
Tag: "LUA",
|
Tag: "LUA",
|
||||||
TagColor: BBlue, // Bold Blue
|
TagColor: BBlue, // Bold Blue
|
||||||
},
|
},
|
||||||
LevelPrefix: {
|
LevelPrefix: {
|
||||||
Tag: "PREFIX", // Used for coloring the user prefix
|
Tag: "PREFIX", // Used for coloring the user prefix
|
||||||
TagColor: BIBlack, // Bold Intense Black (Dark Grey)
|
TagColor: BIGray, // Bold Gray
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logger is our custom logger with level support
|
// Logger is our custom logger with level support
|
||||||
type Logger struct {
|
type Logger struct {
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
out io.Writer
|
out []io.Writer
|
||||||
currentLevel LogLevel
|
currentLevel LogLevel
|
||||||
prefix string
|
prefix string
|
||||||
userPrefix string
|
userPrefix string
|
||||||
@@ -122,6 +131,8 @@ func ParseLevel(levelStr string) LogLevel {
|
|||||||
return LevelDebug
|
return LevelDebug
|
||||||
case "TRACE":
|
case "TRACE":
|
||||||
return LevelTrace
|
return LevelTrace
|
||||||
|
case "DUMP":
|
||||||
|
return LevelDump
|
||||||
case "LUA":
|
case "LUA":
|
||||||
return LevelLua
|
return LevelLua
|
||||||
default:
|
default:
|
||||||
@@ -140,7 +151,7 @@ func (l LogLevel) String() string {
|
|||||||
// New creates a new Logger instance
|
// New creates a new Logger instance
|
||||||
func New(out io.Writer, prefix string, flag int) *Logger {
|
func New(out io.Writer, prefix string, flag int) *Logger {
|
||||||
return &Logger{
|
return &Logger{
|
||||||
out: out,
|
out: []io.Writer{out},
|
||||||
currentLevel: defaultLogLevel,
|
currentLevel: defaultLogLevel,
|
||||||
prefix: prefix,
|
prefix: prefix,
|
||||||
userPrefix: "",
|
userPrefix: "",
|
||||||
@@ -206,7 +217,7 @@ func (l *Logger) ShowGoroutine() bool {
|
|||||||
// WithField adds a field to the logger's context
|
// WithField adds a field to the logger's context
|
||||||
func (l *Logger) WithField(key string, value interface{}) *Logger {
|
func (l *Logger) WithField(key string, value interface{}) *Logger {
|
||||||
newLogger := &Logger{
|
newLogger := &Logger{
|
||||||
out: l.out,
|
out: append([]io.Writer(nil), l.out...),
|
||||||
currentLevel: l.currentLevel,
|
currentLevel: l.currentLevel,
|
||||||
prefix: l.prefix,
|
prefix: l.prefix,
|
||||||
userPrefix: l.userPrefix,
|
userPrefix: l.userPrefix,
|
||||||
@@ -230,7 +241,7 @@ func (l *Logger) WithField(key string, value interface{}) *Logger {
|
|||||||
// WithFields adds multiple fields to the logger's context
|
// WithFields adds multiple fields to the logger's context
|
||||||
func (l *Logger) WithFields(fields map[string]interface{}) *Logger {
|
func (l *Logger) WithFields(fields map[string]interface{}) *Logger {
|
||||||
newLogger := &Logger{
|
newLogger := &Logger{
|
||||||
out: l.out,
|
out: append([]io.Writer(nil), l.out...),
|
||||||
currentLevel: l.currentLevel,
|
currentLevel: l.currentLevel,
|
||||||
prefix: l.prefix,
|
prefix: l.prefix,
|
||||||
userPrefix: l.userPrefix,
|
userPrefix: l.userPrefix,
|
||||||
@@ -261,7 +272,7 @@ func (l *Logger) WithPrefix(prefix string) *Logger {
|
|||||||
l = Default
|
l = Default
|
||||||
}
|
}
|
||||||
newLogger := &Logger{
|
newLogger := &Logger{
|
||||||
out: l.out,
|
out: append([]io.Writer(nil), l.out...),
|
||||||
currentLevel: l.currentLevel,
|
currentLevel: l.currentLevel,
|
||||||
prefix: l.prefix,
|
prefix: l.prefix,
|
||||||
userPrefix: strings.TrimSpace(l.userPrefix + " " + prefix),
|
userPrefix: strings.TrimSpace(l.userPrefix + " " + prefix),
|
||||||
@@ -291,7 +302,7 @@ func (l *Logger) ToFile(filename string) *Logger {
|
|||||||
l = Default
|
l = Default
|
||||||
}
|
}
|
||||||
newLogger := &Logger{
|
newLogger := &Logger{
|
||||||
out: io.MultiWriter(l.out, file),
|
out: append([]io.Writer(nil), l.out...),
|
||||||
currentLevel: l.currentLevel,
|
currentLevel: l.currentLevel,
|
||||||
prefix: l.prefix,
|
prefix: l.prefix,
|
||||||
userPrefix: l.userPrefix,
|
userPrefix: l.userPrefix,
|
||||||
@@ -301,6 +312,12 @@ func (l *Logger) ToFile(filename string) *Logger {
|
|||||||
defaultFields: make(map[string]interface{}),
|
defaultFields: make(map[string]interface{}),
|
||||||
showGoroutine: l.showGoroutine,
|
showGoroutine: l.showGoroutine,
|
||||||
}
|
}
|
||||||
|
// Copy existing fields
|
||||||
|
for k, v := range l.defaultFields {
|
||||||
|
newLogger.defaultFields[k] = v
|
||||||
|
}
|
||||||
|
// Append the new file writer
|
||||||
|
newLogger.out = append(newLogger.out, file)
|
||||||
return newLogger
|
return newLogger
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -478,7 +495,9 @@ func (l *Logger) log(level LogLevel, format string, args ...interface{}) {
|
|||||||
|
|
||||||
// Get formatted message with potential background color
|
// Get formatted message with potential background color
|
||||||
msg := l.formatMessage(level, format, args...)
|
msg := l.formatMessage(level, format, args...)
|
||||||
fmt.Fprintln(l.out, msg)
|
for _, w := range l.out {
|
||||||
|
fmt.Fprintln(w, msg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error logs an error message
|
// Error logs an error message
|
||||||
@@ -506,6 +525,27 @@ func (l *Logger) Trace(format string, args ...interface{}) {
|
|||||||
l.log(LevelTrace, format, args...)
|
l.log(LevelTrace, format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dump logs objects using valast for regressive tests
|
||||||
|
func (l *Logger) Dump(message string, objects ...interface{}) {
|
||||||
|
if len(objects) == 0 {
|
||||||
|
l.log(LevelDump, message)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var dumpContent strings.Builder
|
||||||
|
dumpContent.WriteString(message)
|
||||||
|
dumpContent.WriteString(":\n")
|
||||||
|
|
||||||
|
for i, obj := range objects {
|
||||||
|
if i > 0 {
|
||||||
|
dumpContent.WriteString("\n")
|
||||||
|
}
|
||||||
|
dumpContent.WriteString(valast.String(obj))
|
||||||
|
}
|
||||||
|
|
||||||
|
l.log(LevelDump, dumpContent.String())
|
||||||
|
}
|
||||||
|
|
||||||
// Lua logs a Lua message
|
// Lua logs a Lua message
|
||||||
func (l *Logger) Lua(format string, args ...interface{}) {
|
func (l *Logger) Lua(format string, args ...interface{}) {
|
||||||
l.log(LevelLua, format, args...)
|
l.log(LevelLua, format, args...)
|
||||||
@@ -553,6 +593,14 @@ func Trace(format string, args ...interface{}) {
|
|||||||
Default.Trace(format, args...)
|
Default.Trace(format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dump logs objects using valast for regressive tests using the default logger
|
||||||
|
func Dump(message string, objects ...interface{}) {
|
||||||
|
if Default == nil {
|
||||||
|
Init(defaultLogLevel)
|
||||||
|
}
|
||||||
|
Default.Dump(message, objects...)
|
||||||
|
}
|
||||||
|
|
||||||
// Lua logs a Lua message using the default logger
|
// Lua logs a Lua message using the default logger
|
||||||
func Lua(format string, args ...interface{}) {
|
func Lua(format string, args ...interface{}) {
|
||||||
if Default == nil {
|
if Default == nil {
|
||||||
@@ -620,6 +668,38 @@ func ShowGoroutine() bool {
|
|||||||
return Default.ShowGoroutine()
|
return Default.ShowGoroutine()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *Logger) NoStdout() *Logger {
|
||||||
|
if Default == nil {
|
||||||
|
Init(defaultLogLevel)
|
||||||
|
}
|
||||||
|
if l == nil {
|
||||||
|
l = Default
|
||||||
|
}
|
||||||
|
newLogger := &Logger{
|
||||||
|
out: nil,
|
||||||
|
currentLevel: l.currentLevel,
|
||||||
|
prefix: l.prefix,
|
||||||
|
userPrefix: l.userPrefix,
|
||||||
|
flag: l.flag,
|
||||||
|
useColors: l.useColors,
|
||||||
|
callerOffset: l.callerOffset,
|
||||||
|
defaultFields: make(map[string]interface{}),
|
||||||
|
showGoroutine: l.showGoroutine,
|
||||||
|
}
|
||||||
|
// Copy existing fields
|
||||||
|
for k, v := range l.defaultFields {
|
||||||
|
newLogger.defaultFields[k] = v
|
||||||
|
}
|
||||||
|
// Keep all writers except stdout
|
||||||
|
for _, w := range l.out {
|
||||||
|
if w == os.Stdout {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
newLogger.out = append(newLogger.out, w)
|
||||||
|
}
|
||||||
|
return newLogger
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
Init(LevelDebug)
|
Init(LevelDebug)
|
||||||
|
|
||||||
@@ -658,4 +738,35 @@ func main() {
|
|||||||
// Test with custom prefix
|
// Test with custom prefix
|
||||||
WithField("prefix", "custom").Info("Message with custom prefix")
|
WithField("prefix", "custom").Info("Message with custom prefix")
|
||||||
Lua("This is a Lua message")
|
Lua("This is a Lua message")
|
||||||
|
|
||||||
|
// Test Dump functionality
|
||||||
|
SetLevel(LevelDump) // Set level to show dump messages
|
||||||
|
|
||||||
|
type ProjectData struct {
|
||||||
|
Title string
|
||||||
|
Name string
|
||||||
|
Data string
|
||||||
|
Commits string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Project struct {
|
||||||
|
Id int64
|
||||||
|
Data *ProjectData
|
||||||
|
}
|
||||||
|
|
||||||
|
p := Project{
|
||||||
|
Id: 1,
|
||||||
|
Data: &ProjectData{
|
||||||
|
Title: "Test",
|
||||||
|
Name: "Mihai",
|
||||||
|
Data: "Some data",
|
||||||
|
Commits: "Test Message",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test single object dump
|
||||||
|
Dump("FooBar called", p)
|
||||||
|
|
||||||
|
// Test multiple object dump
|
||||||
|
Dump("Multiple objects", p, fields, "string value", 42)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user