Documentation ¶
Index ¶
Constants ¶
View Source
const ( // Text is plain text log format Text LogFormat = "text" // JSON is json log format JSON LogFormat = "json" // Logstash is json log format with some additional fields required for logstash Logstash LogFormat = "logstash" // Stackdriver is Google cloud FluentD Stackdriver format Stackdriver LogFormat = "stackdriver" // StdErr is os stderr log writer StdErr LogWriter = "stderr" // StdOut is os stdout log writer StdOut LogWriter = "stdout" // Discard is the quite mode for log writer aka /dev/null Discard LogWriter = "discard" // HookLogstash is logstash hook format HookLogstash = "logstash" // HookSyslog is syslog hook format HookSyslog = "syslog" // HookGraylog is graylog hook format HookGraylog = "graylog" )
Variables ¶
View Source
var ( // ErrUnknownLogHookFormat is the error returned when trying to initialise hook of unknown format ErrUnknownLogHookFormat = errors.New("Failed to init log hooks: unknown hook found") // ErrMissingLogHookSetting is the error returned when trying to initialise hook with required settings missing ErrMissingLogHookSetting = errors.New("Failed to init log hooks: missing required hook setting") // ErrFailedToConfigureLogHook is the error returned when hook configuring failed for some reasons ErrFailedToConfigureLogHook = errors.New("Failed to init log hooks: failed to configure hook") )
Functions ¶
func InitDefaults ¶
InitDefaults initialises default logger settings
Types ¶
type LogConfig ¶
type LogConfig struct { Level string `envconfig:"LOG_LEVEL"` Format LogFormat `envconfig:"LOG_FORMAT"` FormatSettings map[string]string `envconfig:"LOG_FORMAT_SETTINGS"` Writer LogWriter `envconfig:"LOG_WRITER"` Hooks LogHooks `envconfig:"LOG_HOOKS"` // contains filtered or unexported fields }
LogConfig is the struct that stores all the logging configuration and routines for applying configurations to logger
func Load ¶
Load loads config values from file, fallback to load from environment variables if file is not found or failed to read
func LoadConfigFromEnv ¶
LoadConfigFromEnv loads config values from environment variables
type LogHooks ¶
type LogHooks []LogHook
LogHooks is collection of enabled hooks
func (*LogHooks) UnmarshalText ¶
UnmarshalText is an implementation of encoding.TextUnmarshaler for LogHooks type
Click to show internal directories.
Click to hide internal directories.