Documentation ¶
Index ¶
- func DPanic(args ...interface{})
- func DPanicf(template string, args ...interface{})
- func Debug(args ...interface{})
- func Debugf(template string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(template string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(template string, args ...interface{})
- func Info(args ...interface{})
- func Infof(template string, args ...interface{})
- func Named(name string)
- func Panic(args ...interface{})
- func Panicf(template string, args ...interface{})
- func SetEncoding(encodingFormat LogEncodingFormat)
- func SetLogLevel(logLevel string)
- func Warn(args ...interface{})
- func Warnf(template string, args ...interface{})
- type Entry
- func (e *Entry) DPanic(args ...interface{})
- func (e *Entry) DPanicf(template string, args ...interface{})
- func (e *Entry) DPanicw(msg string, keysAndValues ...interface{})
- func (e *Entry) Debug(args ...interface{})
- func (e *Entry) Debugf(template string, args ...interface{})
- func (e *Entry) Debugw(msg string, keysAndValues ...interface{})
- func (e *Entry) Error(args ...interface{})
- func (e *Entry) Errorf(template string, args ...interface{})
- func (e *Entry) Errorw(msg string, keysAndValues ...interface{})
- func (e *Entry) Fatal(args ...interface{})
- func (e *Entry) Fatalf(template string, args ...interface{})
- func (e *Entry) Fatalw(msg string, keysAndValues ...interface{})
- func (e *Entry) Info(args ...interface{})
- func (e *Entry) Infof(template string, args ...interface{})
- func (e *Entry) Infow(msg string, keysAndValues ...interface{})
- func (e *Entry) Panic(args ...interface{})
- func (e *Entry) Panicf(template string, args ...interface{})
- func (e *Entry) Panicw(msg string, keysAndValues ...interface{})
- func (e *Entry) Warn(args ...interface{})
- func (e *Entry) Warnf(template string, args ...interface{})
- func (e *Entry) Warnw(msg string, keysAndValues ...interface{})
- func (e *Entry) With(args ...interface{}) *Entry
- func (e *Entry) WithContext(c context.Context) *Entry
- func (e *Entry) WithError(err error) *Entry
- func (e *Entry) WithTime(t time.Time) *Entry
- type LogEncodingFormat
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DPanic ¶
func DPanic(args ...interface{})
DPanic uses fmt.Sprint to construct and log a message. In development, the logger then panics. (See DPanicLevel for details.)
func DPanicf ¶
func DPanicf(template string, args ...interface{})
DPanicf uses fmt.Sprintf to log a templated message. In development, the logger then panics. (See DPanicLevel for details.)
func Debugf ¶
func Debugf(template string, args ...interface{})
Debugf uses fmt.Sprintf to log a templated message.
func Errorf ¶
func Errorf(template string, args ...interface{})
Errorf uses fmt.Sprintf to log a templated message.
func Fatal ¶
func Fatal(args ...interface{})
Fatal uses fmt.Sprint to construct and log a message, then calls os.Exit.
func Fatalf ¶
func Fatalf(template string, args ...interface{})
Fatalf uses fmt.Sprintf to log a templated message, then calls os.Exit.
func Infof ¶
func Infof(template string, args ...interface{})
Infof uses fmt.Sprintf to log a templated message.
func Named ¶
func Named(name string)
Named adds a sub-scope to the logger's name. See Logger.Named for details. Set it to the service name to find the logs related to service easily.
func Panic ¶
func Panic(args ...interface{})
Panic uses fmt.Sprint to construct and log a message, then panics.
func Panicf ¶
func Panicf(template string, args ...interface{})
Panicf uses fmt.Sprintf to log a templated message, then panics.
func SetEncoding ¶
func SetEncoding(encodingFormat LogEncodingFormat)
SetEncoding sets encoding for the log, valid formats are json and console.
func SetLogLevel ¶
func SetLogLevel(logLevel string)
SetLogLevel creates new logger with new log level. If logLevel is not valid, then default log level will be set to 'debug'.
Types ¶
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
func With ¶
func With(args ...interface{}) *Entry
With adds a variadic number of fields to the logging context. It accepts a mix of strongly-typed Field objects and loosely-typed key-value pairs. When processing pairs, the first element of the pair is used as the field key and the second as the field value.
For example,
sugaredLogger.With( "hello", "world", "failure", errors.New("oh no"), Stack(), "count", 42, "user", User{Name: "alice"}, )
is the equivalent of
unsugared.With( String("hello", "world"), String("failure", "oh no"), Stack(), Int("count", 42), Object("user", User{Name: "alice"}), )
Note that the keys in key-value pairs should be strings. In development, passing a non-string key panics. In production, the logger is more forgiving: a separate error is logged, but the key-value pair is skipped and execution continues. Passing an orphaned key triggers similar behavior: panics in development and errors in production.
func WithContext ¶
WithContext add context tag with context value to the log.
func (*Entry) DPanic ¶
func (e *Entry) DPanic(args ...interface{})
DPanic uses fmt.Sprint to construct and log a message. In development, the logger then panics. (See DPanicLevel for details.)
func (*Entry) DPanicf ¶
DPanicf uses fmt.Sprintf to log a templated message. In development, the logger then panics. (See DPanicLevel for details.)
func (*Entry) DPanicw ¶
DPanicw logs a message with some additional context. In development, the logger then panics. (See DPanicLevel for details.) The variadic key-value pairs are treated as they are in With.
func (*Entry) Debug ¶
func (e *Entry) Debug(args ...interface{})
Debug uses fmt.Sprint to construct and log a message.
func (*Entry) Debugw ¶
Debugw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
When debug-level logging is disabled, this is much faster than
s.With(keysAndValues).Debug(msg)
func (*Entry) Error ¶
func (e *Entry) Error(args ...interface{})
Error uses fmt.Sprint to construct and log a message.
func (*Entry) Errorw ¶
Errorw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
func (*Entry) Fatal ¶
func (e *Entry) Fatal(args ...interface{})
Fatal uses fmt.Sprint to construct and log a message, then calls os.Exit.
func (*Entry) Fatalw ¶
Fatalw logs a message with some additional context, then calls os.Exit. The variadic key-value pairs are treated as they are in With.
func (*Entry) Info ¶
func (e *Entry) Info(args ...interface{})
Info uses fmt.Sprint to construct and log a message.
func (*Entry) Infow ¶
Infow logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
func (*Entry) Panic ¶
func (e *Entry) Panic(args ...interface{})
Panic uses fmt.Sprint to construct and log a message, then panics.
func (*Entry) Panicw ¶
Panicw logs a message with some additional context, then panics. The variadic key-value pairs are treated as they are in With.
func (*Entry) Warn ¶
func (e *Entry) Warn(args ...interface{})
Warn uses fmt.Sprint to construct and log a message.
func (*Entry) Warnw ¶
Warnw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
func (*Entry) With ¶
With adds a variadic number of fields to the logging context. It accepts a mix of strongly-typed Field objects and loosely-typed key-value pairs. When processing pairs, the first element of the pair is used as the field key and the second as the field value.
For example,
sugaredLogger.With( "hello", "world", "failure", errors.New("oh no"), Stack(), "count", 42, "user", User{Name: "alice"}, )
is the equivalent of
unsugared.With( String("hello", "world"), String("failure", "oh no"), Stack(), Int("count", 42), Object("user", User{Name: "alice"}), )
Note that the keys in key-value pairs should be strings. In development, passing a non-string key panics. In production, the logger is more forgiving: a separate error is logged, but the key-value pair is skipped and execution continues. Passing an orphaned key triggers similar behavior: panics in development and errors in production.
func (*Entry) WithContext ¶
WithContext add context tag with context value to the log.
type LogEncodingFormat ¶
type LogEncodingFormat string
const ( EncodingConsoleFormat LogEncodingFormat = "console" EncodingJsonFormat LogEncodingFormat = "json" )