logger

package
v2.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Log is the global logger instance
	Log zerolog.Logger
)

Functions

func Current

func Current() *zerolog.Logger

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 Debug

func Debug(msg string)

Debug logs a debug message

func Debugf

func Debugf(format string, args ...interface{})

Debugf logs a formatted debug message

func Error

func Error(msg string)

Error logs an error message

func ErrorErr

func ErrorErr(msg string, err error)

ErrorErr logs an error with an error object

func Errorf

func Errorf(format string, args ...interface{})

Errorf logs a formatted error message

func Fatal

func Fatal(msg string)

Fatal logs a fatal message and exits

func FatalErr

func FatalErr(msg string, err error)

FatalErr logs a fatal message with an error and exits

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf logs a formatted fatal message and exits

func GetGormConfig

func GetGormConfig() *gorm.Config

GetGormConfig returns a gorm.Config with the zerolog-based logger

func GetLevel

func GetLevel() zerolog.Level

GetLevel returns the current log level

func GetWriter

func GetWriter() io.Writer

GetWriter returns an io.Writer that writes to the logger

func Info

func Info(msg string)

Info logs an info message

func Infof

func Infof(format string, args ...interface{})

Infof logs a formatted info message

func Init

func Init(level string)

Init initializes the global logger with the specified level

func IsDebugEnabled

func IsDebugEnabled() bool

IsDebugEnabled returns true if debug logging is enabled

func NewHCLogAdapter

func NewHCLogAdapter(name string) hclog.Logger

NewHCLogAdapter creates a new hclog adapter

func SetLevel

func SetLevel(level string)

SetLevel sets the global log level

func Use

func Use(l zerolog.Logger)

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 Warn

func Warn(msg string)

Warn logs a warning message

func Warnf

func Warnf(format string, args ...interface{})

Warnf logs a formatted warning message

func With

func With() zerolog.Context

With returns a new logger with additional fields

func WithFields

func WithFields(fields map[string]interface{}) zerolog.Logger

WithFields returns a new logger with the given fields

Types

type GormLogger

type GormLogger struct {
	SlowThreshold        time.Duration
	IgnoreRecordNotFound bool
}

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

LogMode implements gorm's logger.Interface

func (*GormLogger) Trace

func (l *GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error)

Trace implements gorm's logger.Interface - logs SQL queries

func (*GormLogger) Warn

func (l *GormLogger) Warn(ctx context.Context, msg string, data ...interface{})

Warn 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) Name

func (h *HCLogAdapter) Name() string

Name returns the logger name

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

type LogLevel

type LogLevel string

LogLevel represents the available log levels

const (
	LevelTrace LogLevel = "trace"
	LevelDebug LogLevel = "debug"
	LevelInfo  LogLevel = "info"
	LevelWarn  LogLevel = "warn"
	LevelError LogLevel = "error"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL