Documentation
¶
Index ¶
- Variables
- func Current() *zerolog.Logger
- func Debug(msg string)
- func Debugf(format string, args ...interface{})
- func Error(msg string)
- func ErrorErr(msg string, err error)
- func Errorf(format string, args ...interface{})
- func Fatal(msg string)
- func FatalErr(msg string, err error)
- func Fatalf(format string, args ...interface{})
- func GetGormConfig() *gorm.Config
- func GetLevel() zerolog.Level
- func GetWriter() io.Writer
- func Info(msg string)
- func Infof(format string, args ...interface{})
- func Init(level string)
- func IsDebugEnabled() bool
- func NewHCLogAdapter(name string) hclog.Logger
- func SetLevel(level string)
- func Use(l zerolog.Logger)
- func Warn(msg string)
- func Warnf(format string, args ...interface{})
- func With() zerolog.Context
- func WithFields(fields map[string]interface{}) zerolog.Logger
- type GormLogger
- func (l *GormLogger) Error(ctx context.Context, msg string, data ...interface{})
- func (l *GormLogger) Info(ctx context.Context, msg string, data ...interface{})
- func (l *GormLogger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
- func (l *GormLogger) Trace(ctx context.Context, begin time.Time, ...)
- func (l *GormLogger) Warn(ctx context.Context, msg string, data ...interface{})
- type HCLogAdapter
- func (h *HCLogAdapter) Debug(msg string, args ...interface{})
- func (h *HCLogAdapter) Error(msg string, args ...interface{})
- func (h *HCLogAdapter) GetLevel() hclog.Level
- func (h *HCLogAdapter) ImpliedArgs() []interface{}
- func (h *HCLogAdapter) Info(msg string, args ...interface{})
- func (h *HCLogAdapter) IsDebug() bool
- func (h *HCLogAdapter) IsError() bool
- func (h *HCLogAdapter) IsInfo() bool
- func (h *HCLogAdapter) IsTrace() bool
- func (h *HCLogAdapter) IsWarn() bool
- func (h *HCLogAdapter) Log(level hclog.Level, msg string, args ...interface{})
- func (h *HCLogAdapter) Name() string
- func (h *HCLogAdapter) Named(name string) hclog.Logger
- func (h *HCLogAdapter) ResetNamed(name string) hclog.Logger
- func (h *HCLogAdapter) SetLevel(level hclog.Level)
- func (h *HCLogAdapter) StandardLogger(opts *hclog.StandardLoggerOptions) *log.Logger
- func (h *HCLogAdapter) StandardWriter(opts *hclog.StandardLoggerOptions) io.Writer
- func (h *HCLogAdapter) Trace(msg string, args ...interface{})
- func (h *HCLogAdapter) Warn(msg string, args ...interface{})
- func (h *HCLogAdapter) With(args ...interface{}) hclog.Logger
- type LogLevel
Constants ¶
This section is empty.
Variables ¶
var ( // Log is the global logger instance Log zerolog.Logger )
Functions ¶
func Current ¶
Current returns Log once Init or Use has set it, and zerolog's global logger before that. Log's zero value discards everything, which suits Studio's routine logging in a process that never sets it up (the microgateway runs Studio packages without calling Init); what must never go unseen, such as a recovered panic, logs through Current instead.
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf logs a formatted fatal message and exits
func GetGormConfig ¶
GetGormConfig returns a gorm.Config with the zerolog-based logger
func IsDebugEnabled ¶
func IsDebugEnabled() bool
IsDebugEnabled returns true if debug logging is enabled
func NewHCLogAdapter ¶
NewHCLogAdapter creates a new hclog adapter
func Use ¶
Use makes l the logger Studio's own logging goes through, without touching zerolog's global logger or level, which belong to an embedding host.
func WithFields ¶
WithFields returns a new logger with the given fields
Types ¶
type GormLogger ¶
GormLogger implements gorm's logger.Interface using zerolog
func NewGormLogger ¶
func NewGormLogger() *GormLogger
NewGormLogger creates a new GORM logger that uses zerolog
func (*GormLogger) Error ¶
func (l *GormLogger) Error(ctx context.Context, msg string, data ...interface{})
Error implements gorm's logger.Interface
func (*GormLogger) Info ¶
func (l *GormLogger) Info(ctx context.Context, msg string, data ...interface{})
Info implements gorm's logger.Interface
func (*GormLogger) LogMode ¶
func (l *GormLogger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
LogMode implements gorm's logger.Interface
type HCLogAdapter ¶
type HCLogAdapter struct {
// contains filtered or unexported fields
}
HCLogAdapter adapts our zerolog logger to the hclog.Logger interface
func (*HCLogAdapter) Debug ¶
func (h *HCLogAdapter) Debug(msg string, args ...interface{})
Debug emits a debug level log
func (*HCLogAdapter) Error ¶
func (h *HCLogAdapter) Error(msg string, args ...interface{})
Error emits an error level log
func (*HCLogAdapter) GetLevel ¶
func (h *HCLogAdapter) GetLevel() hclog.Level
GetLevel returns the current log level
func (*HCLogAdapter) ImpliedArgs ¶
func (h *HCLogAdapter) ImpliedArgs() []interface{}
ImpliedArgs returns any implied arguments
func (*HCLogAdapter) Info ¶
func (h *HCLogAdapter) Info(msg string, args ...interface{})
Info emits an info level log
func (*HCLogAdapter) IsDebug ¶
func (h *HCLogAdapter) IsDebug() bool
IsDebug returns true if debug level is enabled
func (*HCLogAdapter) IsError ¶
func (h *HCLogAdapter) IsError() bool
IsError returns true if error level is enabled
func (*HCLogAdapter) IsInfo ¶
func (h *HCLogAdapter) IsInfo() bool
IsInfo returns true if info level is enabled
func (*HCLogAdapter) IsTrace ¶
func (h *HCLogAdapter) IsTrace() bool
IsTrace returns true if trace level is enabled
func (*HCLogAdapter) IsWarn ¶
func (h *HCLogAdapter) IsWarn() bool
IsWarn returns true if warn level is enabled
func (*HCLogAdapter) Log ¶
func (h *HCLogAdapter) Log(level hclog.Level, msg string, args ...interface{})
Log emits the message at the given level
func (*HCLogAdapter) Named ¶
func (h *HCLogAdapter) Named(name string) hclog.Logger
Named creates a named sublogger
func (*HCLogAdapter) ResetNamed ¶
func (h *HCLogAdapter) ResetNamed(name string) hclog.Logger
ResetNamed creates a logger with the given name
func (*HCLogAdapter) SetLevel ¶
func (h *HCLogAdapter) SetLevel(level hclog.Level)
SetLevel sets the log level
func (*HCLogAdapter) StandardLogger ¶
func (h *HCLogAdapter) StandardLogger(opts *hclog.StandardLoggerOptions) *log.Logger
StandardLogger returns a standard library logger
func (*HCLogAdapter) StandardWriter ¶
func (h *HCLogAdapter) StandardWriter(opts *hclog.StandardLoggerOptions) io.Writer
StandardWriter returns an io.Writer that writes to the logger
func (*HCLogAdapter) Trace ¶
func (h *HCLogAdapter) Trace(msg string, args ...interface{})
Trace emits a trace level log
func (*HCLogAdapter) Warn ¶
func (h *HCLogAdapter) Warn(msg string, args ...interface{})
Warn emits a warn level log
func (*HCLogAdapter) With ¶
func (h *HCLogAdapter) With(args ...interface{}) hclog.Logger
With creates a sublogger with additional fields