Documentation ¶
Index ¶
- func InitLogger(cfg Config) error
- type Config
- type Field
- func Any(key string, value interface{}) Field
- func Error(err error) Field
- func Int32(key string, val int32) Field
- func Int64(key string, val int64) Field
- func Reflect(key string, val interface{}) Field
- func Stack() Field
- func String(key string, val string) Field
- func Uint16(key string, val uint16) Field
- func Uint32(key string, val uint32) Field
- func Uint64(key string, val uint64) Field
- type Logger
- func (l *Logger) Debug(msg string, fields ...Field)
- func (l *Logger) Error(msg string, fields ...Field)
- func (l *Logger) Errorf(template string, args ...interface{})
- func (l *Logger) Fatal(msg string, fields ...Field)
- func (l *Logger) Info(msg string, fields ...Field)
- func (l *Logger) Infof(template string, args ...interface{})
- func (l *Logger) Warn(msg string, fields ...Field)
- func (l *Logger) With(fields ...Field) *Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitLogger ¶
InitLogger initializes a zap logger from user config.
Types ¶
type Config ¶
type Config struct {
Level string `yaml:"level"`
}
Log represents a logging configuration.
type Field ¶
Field represents filed of zap logger.
func Any ¶
Any takes a key and an arbitrary value and chooses the best way to represent them as a field, falling back to a reflection-based approach only if necessary.
func Reflect ¶
Reflect constructs a field with the given key and an arbitrary object. It uses an encoding-appropriate, reflection-based function to lazily serialize nearly any object into the logging context, but it's relatively slow and allocation-heavy. Outside tests, Any is always a better choice.
If encoding fails (e.g., trying to serialize a map[int]string to JSON), Reflect includes the error message in the final log output.
func Stack ¶
func Stack() Field
Stack constructs a field that stores a stacktrace of the current goroutine under provided key. Keep in mind that taking a stacktrace is eager and expensive (relatively speaking); this function both makes an allocation and takes about two microseconds.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is wrapper for zap logger with module, it is singleton.
func (*Logger) Debug ¶
Debug logs a message at DebugLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func (*Logger) Error ¶
Error logs a message at ErrorLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func (*Logger) Fatal ¶
Fatal logs a message at FatalLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func (*Logger) Info ¶
Info logs a message at InfoLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.