{"modulePath":"github.com/foxcpp/maddy","version":"v0.9.8","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package log\n\nPackage log implements a minimalistic logging library.\n\n## Variables\n\n```go\nvar DefaultLogger = Logger{Out: WriterOutput(os.Stderr, false)}\n```\nDefaultLogger is the global Logger object that is used by package-level logging functions.\n\nAs with all other Loggers, it is not gorountine-safe on its own, however underlying log.Output may provide necessary serialization.\n\n```go\nvar NopLogger = Logger{\n\tParent: \u0026DefaultLogger,\n\tOut:    NopOutput{},\n}\n```\nNopLogger is the logger that discards all messages written to it.\n\n## Functions\n\n```go\nfunc Debugf(format string, val ...interface{})\n```\n\n```go\nfunc Debugln(val ...interface{})\n```\n\n```go\nfunc Printf(format string, val ...interface{})\n```\n\n```go\nfunc Println(val ...interface{})\n```\n\n## Types\n\n```go\ntype Formatter interface {\n\tFormatLog() string\n}\n```\n\n```go\ntype Logger struct {\n\tParent *Logger\n\n\tOut   Output\n\tName  string\n\tDebug bool\n\n\t// Additional fields that will be added\n\t// to the Msg output.\n\tFields map[string]interface{}\n}\n```\nLogger is the structure that writes formatted output to the underlying log.Output object.\n\nLogger is stateless and can be copied freely.  However, consider that underlying log.Output will not be copied.\n\nEach log message is prefixed with logger name.  Timestamp and debug flag formatting is done by log.Output.\n\nNo serialization is provided by Logger, its log.Output responsibility to ensure goroutine-safety if necessary.\n\n```go\nfunc (l *Logger) Close() error\n```\nClose closes underlying output in Out.\n\n```go\nfunc (l *Logger) DebugMsg(kind string, fields ...interface{})\n```\n\n```go\nfunc (l *Logger) DebugWriter() io.Writer\n```\nDebugWriter returns a writer that will act like Logger.Write but will use debug flag on messages. If Logger.Debug is false, Write method of returned object will be no-op.\n\n```go\nfunc (l *Logger) Debugf(format string, val ...interface{})\n```\n\n```go\nfunc (l *Logger) Debugln(val ...interface{})\n```\n\n```go\nfunc (l *Logger) Error(msg string, err error, fields ...interface{})\n```\nError writes an event log message in a machine-readable format (currently JSON) containing information about the error. If err does have a Fields method that returns map\\[string]interface{}, its result will be added to the message.\n\n\tname: msg\\t{\"key\":\"value\",\"key2\":\"value2\"}\n\nAdditionally, values from fields will be added to it, as handled by Logger.Msg.\n\nIn the context of Error method, \"msg\" typically indicates the top-level context in which the error is \\*handled\\*. For example, if error leads to rejection of SMTP DATA command, msg will probably be \"DATA error\".\n\n```go\nfunc (l *Logger) IsDebug() bool\n```\n\n```go\nfunc (l *Logger) Msg(msg string, fields ...interface{})\n```\nMsg writes an event log message in a machine-readable format (currently JSON).\n\n\tname: msg\\t{\"key\":\"value\",\"key2\":\"value2\"}\n\nKey-value pairs are built from fields slice which should contain key strings followed by corresponding values.  That is, for example, \\[]interface{\"key\", \"value\", \"key2\", \"value2\"}.\n\nIf value in fields implements Formatter, it will be represented by the string returned by FormatLog method. Same goes for fmt.Stringer and error interfaces.\n\nAdditionally, time.Time is written as a string in ISO 8601 format. time.Duration follows fmt.Stringer rule above.\n\n```go\nfunc (l *Logger) Printf(format string, val ...interface{})\n```\n\n```go\nfunc (l *Logger) Println(val ...interface{})\n```\n\n```go\nfunc (l *Logger) Sublogger(name string) *Logger\n```\n\n```go\nfunc (l *Logger) Write(s []byte) (int, error)\n```\nWrite implements io.Writer, all bytes sent to it will be written as a separate log messages. No line-buffering is done.\n\n```go\nfunc (l *Logger) Zap() *zap.Logger\n```\n\n```go\ntype NopOutput struct{}\n```\n\n```go\nfunc (NopOutput) Close() error\n```\n\n```go\nfunc (NopOutput) Write(time.Time, bool, string)\n```\n\n```go\ntype Output interface {\n\tWrite(stamp time.Time, debug bool, msg string)\n\tClose() error\n}\n```\n\n```go\nfunc FuncOutput(f func(time.Time, bool, string), close func() error) Output\n```\n\n```go\nfunc MultiOutput(outputs ...Output) Output\n```\n\n```go\nfunc SyslogOutput() (Output, error)\n```\nSyslogOutput returns a log.Output implementation that will send messages to the system syslog daemon.\n\nRegular messages will be written with INFO priority, debug messages will be written with DEBUG priority.\n\nReturned log.Output object is goroutine-safe.\n\n```go\nfunc WriteCloserOutput(wc io.WriteCloser, timestamps bool) Output\n```\nWriteCloserOutput returns a log.Output implementation that will write formatted messages to the provided io.Writer.\n\nClosing returned log.Output object will close the underlying io.WriteCloser.\n\nWritten messages will include timestamp formatted with millisecond precision and \\[debug] prefix for debug messages. If timestamps argument is false, timestamps will not be added.\n\nReturned log.Output does not provide its own serialization so goroutine-safety depends on the io.Writer. Most operating systems have atomic (read: thread-safe) implementations for stream I/O, so it should be safe to use WriterOutput with os.File.\n\n```go\nfunc WriterOutput(w io.Writer, timestamps bool) Output\n```\nWriterOutput returns a log.Output implementation that will write formatted messages to the provided io.Writer.\n\nClosing returned log.Output object will have no effect on the underlying io.Writer.\n\nWritten messages will include timestamp formatted with millisecond precision and \\[debug] prefix for debug messages. If timestamps argument is false, timestamps will not be added.\n\nReturned log.Output does not provide its own serialization so goroutine-safety depends on the io.Writer. Most operating systems have atomic (read: thread-safe) implementations for stream I/O, so it should be safe to use WriterOutput with os.File.\n\n","path":"github.com/foxcpp/maddy/framework/log","name":"log","synopsis":"Package log implements a minimalistic logging library.","isRedistributable":true}
