logx

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

README

logx

This package is only a wrapper on top uber's zap logger. This package is only for learning and not tested.

Inspired from: https://www.mountedthoughts.com/golang-logger-interface/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CustomLevelEncoder

func CustomLevelEncoder(level zapcore.Level, enc zapcore.PrimitiveArrayEncoder)

func Debug

func Debug(args ...interface{})

Debug logs a message at DebugLevel

func Debugf

func Debugf(format string, args ...interface{})

Debugf logs a message at DebugLevel with string format

func Error

func Error(args ...interface{})

Error logs a message at ErrorLevel

func Errorf

func Errorf(format string, args ...interface{})

Errorf logs a message at ErrorLevel with string format

func Fatal

func Fatal(args ...interface{})

Fatal logs a message at FatalLevel

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf logs a message at FatalLevel with string format

func Info

func Info(args ...interface{})

Info logs a message at InfoLevel

func Infof

func Infof(format string, args ...interface{})

Infof logs a message at InfoLevel with string format

func Panic

func Panic(args ...interface{})

Panic logs a message at PanicLevel

func Panicf

func Panicf(format string, args ...interface{})

Panicf logs a message at PanicLevel with string format

func Print

func Print(args ...interface{})

Print logs a message at InfoLevel

func Printf

func Printf(format string, args ...interface{})

Printf logs a message at InfoLevel with string format

func Println

func Println(args ...interface{})

Println logs a message at InfoLevel

func SyslogTimeEncoder

func SyslogTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)

func Warn

func Warn(args ...interface{})

Warn logs a message at WarnLevel

func Warnf

func Warnf(format string, args ...interface{})

Warnf logs a message at WarnLevel with string format

Types

type Fields

type Fields map[string]interface{}

Fields Type to pass when we want to call WithFields for structured logging

type ILogger

type ILogger interface {
	Error(args ...interface{})
	Errorf(format string, args ...interface{})

	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})

	Info(args ...interface{})
	Infof(format string, args ...interface{})

	Warn(args ...interface{})
	Warnf(format string, args ...interface{})

	Debug(args ...interface{})
	Debugf(format string, args ...interface{})

	Panic(args ...interface{})
	Panicf(format string, args ...interface{})

	Print(args ...interface{})
	Printf(format string, args ...interface{})
	Println(args ...interface{})

	WithFields(keyValues Fields) ILogger
	WithField(key string, value interface{}) ILogger
}

ILogger is our contract for the logger

func NewZapLogger

func NewZapLogger() ILogger

func WithField added in v0.0.2

func WithField(key string, value interface{}) ILogger

WithField returns a new logger instance which can Log a message at the given level with a key and a value

func WithFields

func WithFields(keyValues Fields) ILogger

WithFields returns a new logger instance which can Log a message at the given level with context key/value pairs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL