Documentation ¶
Index ¶
- Constants
- Variables
- func Debug(arg ...any)
- func Debugf(format string, arg ...any)
- func Error(err error)
- func Fatal(err error)
- func Info(arg ...any)
- func Infof(format string, arg ...any)
- func Panic(err error)
- func SetIndentEncoder()
- func SetInlineEncoder()
- func SetLevel(v Level)
- func SetLogger(l func(Entry))
- func Warn(arg ...any)
- func Warnf(format string, arg ...any)
- type Entry
- type Level
Constants ¶
View Source
const ( DebugLevel Level = iota InfoLevel WarningLevel ErrorLevel AppKeyTag = "app_key" SessionIDTag = "session_id" ParticipantIDTag = "participant_id" ClientIDTag = "client_id" )
Available log levels.
Variables ¶
View Source
var ( // The function to encode log entries and their tags. Encoder func(any) ([]byte, error) )
Functions ¶
func SetIndentEncoder ¶
func SetIndentEncoder()
SetIndentEncoder is a helper function that set the error encoder to a function that uses json.MarshalIndent.
func SetInlineEncoder ¶
func SetInlineEncoder()
SetInlineEncoder is a helper function that set the error encoder to json.Marshal.
Types ¶
type Entry ¶
type Entry interface { // Return the time when the entry was created. Time() time.Time // Returns the log level. Level() Level // Sets the tag key with the given value. The value is converted to a // string. WithTag(k string, v any) Entry // Set Client ID tag WithClientID(v string) Entry // Set opentelemetry context tags WithOtelCtx(ctx context.Context) Entry // Returns the log tags. Tags() map[string]any // Logs the given values with debug level. Debug(v ...any) // Logs the velues with the given format on with debug level. Debugf(format string, v ...any) // Logs the given values with info level. Info(v ...any) // Logs the velues with the given format on with info level. Infof(format string, v ...any) // Logs the given values with warning level. Warn(v ...any) // Logs the velues with the given format on with warning level. Warnf(format string, v ...any) // Logs the given values with error level. Error(error) // Logs error on error level and exit with status 1. Fatal(err error) // Logs error on error level and panic Panic(err error) // Returns the error used to create the entry. GetError() error // Return the entry as a string. String() string }
func WithOtelCtx ¶
Creates a log entry with opentelemetry context tags
Click to show internal directories.
Click to hide internal directories.