Documentation ¶
Index ¶
Constants ¶
const ( CONSOLE = "console" JOURNAL = "systemd-journald" )
Variables ¶
This section is empty.
Functions ¶
func AssertOutput ¶
AssertOutput returns an error if output is not a valid logger output.
func Fatal ¶
func Fatal(err error)
Fatal logs the given error and its stack trace to the console and then exits. This function is to be used if Logging has not yet been created or could not be created.
func NewJournaldCore ¶
func NewJournaldCore(identifier string, enab zapcore.LevelEnabler) zapcore.Core
NewJournaldCore returns a zapcore.Core that sends log entries to systemd-journald and uses the given identifier as a prefix for structured logging context that is sent as journal fields.
Types ¶
type Config ¶
type Config struct { // zapcore.Level at 0 is for info level. Level zapcore.Level `yaml:"level" default:"0"` Output string `yaml:"output"` // Interval for periodic logging. Interval time.Duration `yaml:"interval" default:"20s"` Options `yaml:"options"` }
Config defines Logger configuration.
type Logger ¶
type Logger struct { *zap.SugaredLogger // contains filtered or unexported fields }
Logger wraps zap.SugaredLogger and allows to get the interval for periodic logging.
type Logging ¶
type Logging struct {
// contains filtered or unexported fields
}
Logging implements access to a default logger and named child loggers. Log levels can be configured per named child via Options which, if not configured, fall back on a default log level. Logs either to the console or to systemd-journald.
func NewLogging ¶
func NewLogging(name string, level zapcore.Level, output string, options Options, interval time.Duration) (*Logging, error)
NewLogging takes the name and log level for the default logger, output where log messages are written to, options having log levels for named child loggers and returns a new Logging.
func NewLoggingFromConfig ¶
NewLoggingFromConfig returns a new Logging from Config.
func (*Logging) GetChildLogger ¶
GetChildLogger returns a named child logger. Log levels for named child loggers are obtained from the logging options and, if not found, set to the default log level.