Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CustomLogger ¶
type CustomLogger interface { Fatal(err error) Error(err error) Warn(err error) Info(err error) Debug(err error) }
CustomLogger interface for custom logging implementations
type DefaultLogger ¶
type DefaultLogger struct {
// contains filtered or unexported fields
}
DefaultLogger default logging controller
func NewDefaultLogger ¶
func NewDefaultLogger(level Level, writer io.Writer) (d *DefaultLogger)
NewDefaultLogger constructor
func (*DefaultLogger) Debug ¶
func (l *DefaultLogger) Debug(err error)
Debug logging level
Example ¶
package main import ( "fmt" "os" "github.com/ao-concepts/core/pkg/log" ) func main() { l := log.NewDefaultLogger(log.Debug, os.Stdout) l.Debug(fmt.Errorf("debug")) l.Info(fmt.Errorf("info")) l.Warn(fmt.Errorf("warn")) l.Error(fmt.Errorf("error")) }
Output: {"level":"debug","error":"debug","message":"debug"} {"level":"info","error":"info","message":"info"} {"level":"warn","error":"warn","message":"warn"} {"level":"error","error":"error","message":"error"}
Example (Uninitialized) ¶
package main import ( "fmt" "github.com/ao-concepts/core/pkg/log" ) func main() { l := log.DefaultLogger{} l.Debug(fmt.Errorf("debug")) l.Info(fmt.Errorf("info")) l.Warn(fmt.Errorf("warn")) l.Error(fmt.Errorf("error")) }
Output:
func (*DefaultLogger) Error ¶
func (l *DefaultLogger) Error(err error)
Error logging level
Example ¶
package main import ( "fmt" "os" "github.com/ao-concepts/core/pkg/log" ) func main() { l := log.NewDefaultLogger(log.Error, os.Stdout) l.Debug(fmt.Errorf("debug")) l.Info(fmt.Errorf("info")) l.Warn(fmt.Errorf("warn")) l.Error(fmt.Errorf("error")) }
Output: {"level":"error","error":"error","message":"error"}
func (*DefaultLogger) Fatal ¶
func (l *DefaultLogger) Fatal(err error)
Fatal logging level
Example ¶
package main import ( "fmt" "os" "github.com/ao-concepts/core/pkg/log" ) func main() { l := log.NewDefaultLogger(log.Fatal, os.Stdout) l.Debug(fmt.Errorf("debug")) l.Info(fmt.Errorf("info")) l.Warn(fmt.Errorf("warn")) l.Error(fmt.Errorf("error")) }
Output:
func (*DefaultLogger) Info ¶
func (l *DefaultLogger) Info(err error)
Info logging level
Example ¶
package main import ( "fmt" "os" "github.com/ao-concepts/core/pkg/log" ) func main() { l := log.NewDefaultLogger(log.Info, os.Stdout) l.Debug(fmt.Errorf("debug")) l.Info(fmt.Errorf("info")) l.Warn(fmt.Errorf("warn")) l.Error(fmt.Errorf("error")) }
Output: {"level":"info","error":"info","message":"info"} {"level":"warn","error":"warn","message":"warn"} {"level":"error","error":"error","message":"error"}
func (*DefaultLogger) Warn ¶
func (l *DefaultLogger) Warn(err error)
Warn logging level
Example ¶
package main import ( "fmt" "os" "github.com/ao-concepts/core/pkg/log" ) func main() { l := log.NewDefaultLogger(log.Warn, os.Stdout) l.Debug(fmt.Errorf("debug")) l.Info(fmt.Errorf("info")) l.Warn(fmt.Errorf("warn")) l.Error(fmt.Errorf("error")) }
Output: {"level":"warn","error":"warn","message":"warn"} {"level":"error","error":"error","message":"error"}
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger logging controller
func NewLogger ¶
func NewLogger(level Level, logger CustomLogger) *Logger
NewLogger constructor. Uses the DefaultLogger if the logger parameter is nil.
Example ¶
package main import ( "fmt" "github.com/ao-concepts/core/pkg/log" ) func main() { l := log.NewLogger(log.Debug, nil) l.Debug(fmt.Errorf("debug")) l.Info(fmt.Errorf("info")) l.Warn(fmt.Errorf("warn")) l.Error(fmt.Errorf("error")) }
Output: {"level":"debug","error":"debug","message":"debug"} {"level":"info","error":"info","message":"info"} {"level":"warn","error":"warn","message":"warn"} {"level":"error","error":"error","message":"error"}
func (*Logger) CreateGinLoggers ¶
func (l *Logger) CreateGinLoggers() []gin.HandlerFunc
CreateGinLoggers mocks this logger for usage with gin (logging, recovery)
func (*Logger) CreateGormLogger ¶
CreateGormLogger mocks this logger for usage with gorm
Click to show internal directories.
Click to hide internal directories.