Documentation ¶
Index ¶
- Variables
- func Debug() *zerolog.Event
- func Duration(msg string, start time.Time)
- func Err(err error) *zerolog.Event
- func Error() *zerolog.Event
- func Fatal() *zerolog.Event
- func Info() *zerolog.Event
- func Panic() *zerolog.Event
- func SetLogLevel(l string) error
- func SetLogOutput(w io.Writer)
- func Trace() *zerolog.Event
- func Track(msg string) (string, time.Time)
- func Warn() *zerolog.Event
- type DBSQLLogger
Constants ¶
This section is empty.
Variables ¶
var Logger = &DBSQLLogger{ zerolog.New(os.Stderr).With().Timestamp().Logger(), }
Functions ¶
func Debug ¶
Sets log to debug. 0 You must call Msg on the returned event in order to send the event.
func Err ¶
Err starts a new message with error level with err as a field if not nil or with info level if err is nil. You must call Msg on the returned event in order to send the event.
func Error ¶
Sets log to error. 3 You must call Msg on the returned event in order to send the event.
func Fatal ¶
Sets log to fatal. 4 You must call Msg on the returned event in order to send the event.
func Panic ¶
Sets log to panic. 5 You must call Msg on the returned event in order to send the event.
func SetLogLevel ¶
Sets log level. Default is "warn" Available levels are: "trace" "debug" "info" "warn" "error" "fatal" "panic" or "disabled"
func SetLogOutput ¶
Sets logging output. Default is os.Stderr. If in terminal, pretty logs are enabled.
func Trace ¶
Sets log to trace. -1 You must call Msg on the returned event in order to send the event.
Types ¶
type DBSQLLogger ¶
func WithContext ¶
func WithContext(connectionId string, correlationId string, queryId string) *DBSQLLogger
WithContext sets connectionId, correlationId, and queryId to be used as fields.
func (*DBSQLLogger) Duration ¶
func (l *DBSQLLogger) Duration(msg string, start time.Time)
Duration logs a debug message with the time elapsed between the provided start and the current time. Use in conjunction with Track.
For example:
msg, start := log.Track("Run operation") defer log.Duration(msg, start)
func (*DBSQLLogger) Track ¶
func (l *DBSQLLogger) Track(msg string) (string, time.Time)
Track is a simple utility function to use with logger to log a message with a timestamp. Recommended to use in conjunction with Duration.
For example:
msg, start := log.Track("Run operation") defer log.Duration(msg, start)