Documentation ¶
Index ¶
- Constants
- func ClearAllContext()
- func ClearContext(key string)
- func InitializeGlobalLogger()
- func PrintDebug()
- func SetContext(key string, value interface{})
- func UpdateGlobalConfig(config GlobalConfig)
- func UpdateGlobalConfigFromFile(fileURL string) error
- type Context
- type ContextLogger
- func (c *ContextLogger) ChangeLevel(newLevel LogLevel)
- func (c *ContextLogger) Debug(format string, args ...interface{})
- func (c *ContextLogger) Error(format string, args ...interface{})
- func (c *ContextLogger) GetLevel() LogLevel
- func (c *ContextLogger) Info(format string, args ...interface{})
- func (c *ContextLogger) Trace(format string, args ...interface{})
- func (c *ContextLogger) Warning(format string, args ...interface{})
- type GlobalConfig
- type LogLevel
- type Logger
- type PackageNameResolver
Constants ¶
const KeyNodeID = "NodeID"
const (
TimeLocationLocal = "Local"
)
Variables ¶
This section is empty.
Functions ¶
func ClearContext ¶
func ClearContext(key string)
ClearContext will clear a context key from all loggers
func InitializeGlobalLogger ¶
func InitializeGlobalLogger()
InitializeGlobalLogger initializes global logger with default configuration if it hasn't been initialized already. If it has been initialized, does nothing.
func SetContext ¶
func SetContext(key string, value interface{})
SetContext sets context for all loggers
func UpdateGlobalConfig ¶
func UpdateGlobalConfig(config GlobalConfig)
UpdateGlobalConfig Updates global config and updates all loggers accordingly Sets only fields that are non-nil
func UpdateGlobalConfigFromFile ¶
UpdateGlobalConfigFromFile reads the file and parses it as YAML. Global logger configuration is updated accordingly. In case of an error, logger won't be updated.
Types ¶
type ContextLogger ¶
type ContextLogger struct {
// contains filtered or unexported fields
}
func (*ContextLogger) ChangeLevel ¶
func (c *ContextLogger) ChangeLevel(newLevel LogLevel)
ChangeLevel changes the level of the context logger.
func (*ContextLogger) Debug ¶
func (c *ContextLogger) Debug(format string, args ...interface{})
func (*ContextLogger) Error ¶
func (c *ContextLogger) Error(format string, args ...interface{})
func (*ContextLogger) GetLevel ¶
func (c *ContextLogger) GetLevel() LogLevel
func (*ContextLogger) Info ¶
func (c *ContextLogger) Info(format string, args ...interface{})
func (*ContextLogger) Trace ¶
func (c *ContextLogger) Trace(format string, args ...interface{})
func (*ContextLogger) Warning ¶
func (c *ContextLogger) Warning(format string, args ...interface{})
type GlobalConfig ¶
type GlobalConfig struct { DefaultLevel LogLevel PackageLevels map[string]LogLevel Writer io.Writer // Writer for log output. By default os.Stdout ConsoleFormat bool // set to true for human-readable output. By default, uses JSON output. ShowCaller bool // set to true to show caller in the log message. By default, true. TimeLocation string // the location for displaying time, by default OS local time. ShowGoroutineID bool // set to true to add goroutine id to the messages. By default, false. ShowNodeID bool // set to true to add node id to the messages. By default, false. }
func BenchmarkConfiguration ¶
func BenchmarkConfiguration() GlobalConfig
BenchmarkConfiguration is a quiet configuration meant for benchmarks.
type Logger ¶
type Logger interface { Trace(format string, args ...interface{}) Debug(format string, args ...interface{}) Info(format string, args ...interface{}) Warning(format string, args ...interface{}) Error(format string, args ...interface{}) // ChangeLevel changes logger level to the newLevel ChangeLevel(newLevel LogLevel) GetLevel() LogLevel }
func CreateForPackage ¶
func CreateForPackage() Logger
CreateForPackage creates logger named after the caller package.
type PackageNameResolver ¶
func (*PackageNameResolver) PackageName ¶
func (r *PackageNameResolver) PackageName() string