Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Console ¶
type Console interface { // Log prints the message to the console. Log(level LogLevel, msg string) }
Console prints an output to a live terminal.
type JSON ¶
type JSON interface { // Log sends a JSON representation of the log message. Log(level LogLevel, data interface{}) }
JSON sends a serialized JSON representation of the log message.
func NewZeroLog ¶
NewZeroLog creates a new JSON that writes to a zerolog.Logger.
It can make use of messages that implement the ZerologMessage interface.
type LogLevel ¶
type LogLevel string
LogLevel specify the importance of the log message. Some implementations may use different channels depending on the log level.
const ( // LogLevelInfo is the lowest log level. It is used for general information messages. LogLevelInfo LogLevel = "INFO" // LogLevelWarning is used for messages that are not errors but may require attention. LogLevelWarning LogLevel = "WARNING" // LogLevelError is used for messages that indicate an error occurred. LogLevelError LogLevel = "ERROR" // LogLevelFatal is used for messages that indicate a fatal error occurred. A logger implementation should // automatically exit the program, or trigger a crash, after logging a message with this level. LogLevelFatal LogLevel = "FATAL" )
type ZerologMessage ¶
type ZerologMessage interface { // ZeroLog shapes, and sends a customized message using zerolog event. ZeroLog(e *zerolog.Event) }
ZerologMessage is a custom interface messages can use to customize the zerolog event.
If a message implements this interface, the logger will rely on the ZeroLog method to produce a message, rather than doing it itself.
The ZeroLog method is responsible for triggering the message with e.Msg or e.Msgf.
This method is only called for top-level messages. Nested messages will use the default serialization behavior.
func AsZeroLoggable ¶
func AsZeroLoggable(data interface{}) (ZerologMessage, bool)
AsZeroLoggable checks if an interface implements the ZerologMessage interface. It returns the underlying implementation on success.