Documentation
¶
Index ¶
- type Json
- func (j *Json) Copy() *Json
- func (j *Json) Error(message string) error
- func (j *Json) Errorf(format string, args ...any) error
- func (j *Json) Info(message string) error
- func (j *Json) Infof(format string, args ...any) error
- func (j *Json) Print(level Level, message string) error
- func (j *Json) Printf(level Level, format string, args ...any) error
- func (j *Json) Trace(message string) error
- func (j *Json) Tracef(format string, args ...any) error
- func (j *Json) Warn(message string) error
- func (j *Json) Warnf(format string, args ...any) error
- func (j *Json) WithError(err error) Logger
- func (j *Json) WithField(key string, value interface{}) Logger
- func (j *Json) WithFields(fields map[string]interface{}) Logger
- type Level
- type Logger
- type Text
- func (text *Text) Copy() *Text
- func (text *Text) Error(message string) error
- func (text *Text) Errorf(format string, args ...any) error
- func (text *Text) Info(message string) error
- func (text *Text) Infof(format string, args ...any) error
- func (text *Text) Print(level Level, message string) error
- func (text *Text) Printf(level Level, format string, args ...any) error
- func (text *Text) Trace(message string) error
- func (text *Text) Tracef(format string, args ...any) error
- func (text *Text) Warn(message string) error
- func (text *Text) Warnf(format string, args ...any) error
- func (text *Text) WithError(err error) Logger
- func (text *Text) WithField(key string, value interface{}) Logger
- func (text *Text) WithFields(fields map[string]interface{}) Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Json ¶
type Json struct { // Level is the log level this Text logger will include in its output. // // This defaults to Info. Level Level // Out is the stream that this Text logger will write to. // // This defaults to os.Stderr. Out io.Writer // DateTimeFormat is the format any log messages should write the date and // time of the format. // // This should be provided in the same format that is supported by the // Time.Format function: https://pkg.go.dev/time#Time.Format. // // This defaults to time.RFC3339Nano. DateTimeFormat string // AdditionalFields contains any extra fields that should be attached to the // written log entries. AdditionalFields map[string]interface{} // contains filtered or unexported fields }
func JsonLogger ¶
func JsonLogger() *Json
func (*Json) WithFields ¶
type Logger ¶
type Logger interface { Print(level Level, message string) error Printf(level Level, format string, args ...any) error Error(message string) error Errorf(format string, args ...any) error Warn(message string) error Warnf(format string, args ...any) error Info(message string) error Infof(format string, args ...any) error Trace(message string) error Tracef(format string, args ...any) error WithError(err error) Logger WithField(key string, value interface{}) Logger WithFields(fields map[string]interface{}) Logger }
type Text ¶
type Text struct { // Level is the log level this Text logger will include in its output. // // This defaults to Info. Level Level // Out is the stream that this Text logger will write to. // // This defaults to os.Stderr. Out io.Writer // Format is the format this Text logger will write log messages. // // This defaults to "[%L] %T: %e%m%f\n". // // It can be overridden to customise the format of the log messages. The // following elements are supported: // - %m: The actual log message. // - %T: The date time of the log message, this can be further customised // by editing the DateTimeFormat field. // - %L: The current log level. // - %e: The value for any attached error, this can be further customised. // - %f: The value for any additional fields, this can be further // customised by editing the AdditionalFieldsFormat field. Format string // DateTimeFormat is the format any log messages should write the date and // time of the format. // // This should be provided in the same format that is supported by the // Time.Format function: https://pkg.go.dev/time#Time.Format. // // This defaults to time.RFC3339Nano. DateTimeFormat string // ErrorFormat describes how any attached error should be rendered. // // This defaults to "(%s) ", the %s is where the error will be rendered. ErrorFormat string // AdditionalFieldsFormat describes how any additional fields should be // rendered. // // This defaults to " [%s]", where %s is the fields joined into a writable // list format using the ',' character. AdditionalFieldsFormat string // AdditionalFields contains any extra fields that should be attached to the // written log entries. // // The key for a field can be specified in the Format preceded by a '%' // character in order to customise exactly where the additional fields will // be rendered. You can also override existing keys using the // AdditionalFields parameter. // // Or, you can specify %f to render all the fields using the // AdditionalFieldsFormat parameter. AdditionalFields map[string]interface{} // contains filtered or unexported fields }
Text is a simple Logger that writes messages in a given format to a specified output. It is designed to write out human-readable logs.
func TextLogger ¶
func TextLogger() *Text
func (*Text) WithFields ¶
Click to show internal directories.
Click to hide internal directories.