Documentation ¶
Overview ¶
Package log provides functionality for logging messages at various severity levels in the Starlark environment.
Index ¶
Constants ¶
const ModuleName = "log"
ModuleName defines the expected name for this Module when used in starlark's load() function, eg: load('log', 'info')
Variables ¶
var ( // LoadModule loads the default log module. It is concurrency-safe and idempotent. LoadModule = defaultModule.LoadModule // SetLog sets the logger of the default log module from outside the package. If l is nil, a noop logger is used, which does nothing. SetLog = defaultModule.SetLog )
Initialized as global functions to be used as default
Functions ¶
func NewDefaultLogger ¶
func NewDefaultLogger() *zap.SugaredLogger
NewDefaultLogger creates a new logger as a default. It is used when no logger is provided to NewModule.
Types ¶
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module wraps the starlark module for the log package.
func NewModule ¶
func NewModule(lg *zap.SugaredLogger) *Module
NewModule creates a new log module. If logger is nil, a new development logger is created.
func (*Module) LoadModule ¶
func (m *Module) LoadModule() (starlark.StringDict, error)
LoadModule returns the log module loader. It is concurrency-safe and idempotent.
func (*Module) SetLog ¶
func (m *Module) SetLog(l *zap.SugaredLogger)
SetLog sets the logger of the log module from outside the package. If l is nil, a noop logger is used, which does nothing.