logger

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2021 License: MIT Imports: 2 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// DEBUG has verbose message
	DEBUG = "debug"
	// INFO is default log level
	INFO = "info"
	// WARN is for logging messages about possible issues
	WARN = "warn"
	// ERROR is for logging errors
	ERROR = "error"
	// FATAL is for logging fatal messages. The sytem shutsdown after logging the message.
	FATAL = "fatal"
)

Variables

This section is empty.

Functions

func Debug

func Debug(msg string)

Debug log a debug message.

func Debugf

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

Debugf uses fmt.Sprintf to log a templated message.

func Debugw

func Debugw(msg string, keysAndValues ...interface{})

Debugw logs a message with some additional context, With key and values, example: log.Debugw("message", "url", url, "attempt", 3) Keys in key-value pairs should be strings.

func Error

func Error(msg string)

Error log a error message.

func Errorf

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

Errorf uses fmt.Sprintf to log a templated message.

func Errorw

func Errorw(msg string, keysAndValues ...interface{})

Errorw logs a message with some additional context, With key and values, example: log.Errorw("message", "url", url, "attempt", 3) Keys in key-value pairs should be strings.

func Fatal

func Fatal(msg string)

Fatal log a fatal message.

func Fatalf

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

Fatalf uses fmt.Sprintf to log a templated message.

func Fatalw

func Fatalw(msg string, keysAndValues ...interface{})

Fatalw logs a message with some additional context, With key and values, example: log.Fatalw("message", "url", url, "attempt", 3) Keys in key-value pairs should be strings.

func Info

func Info(msg string)

Info log a info message.

func Infof

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

Infof uses fmt.Sprintf to log a templated message.

func Infow

func Infow(msg string, keysAndValues ...interface{})

Infow logs a message with some additional context, With key and values, example: log.Infow("message", "url", url, "attempt", 3) Keys in key-value pairs should be strings.

func NewLogger

func NewLogger(config Configuration) error

NewLogger returns an instance of logger

func Panic

func Panic(msg string)

Panic log a panic message.

func Panicf

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

Panicf uses fmt.Sprintf to log a templated message.

func Panicw

func Panicw(msg string, keysAndValues ...interface{})

Panicw logs a message with some additional context, With key and values, example: log.Panicw("message", "url", url, "attempt", 3) Keys in key-value pairs should be strings.

func Warn

func Warn(msg string)

Warn log a warn message.

func Warnf

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

Warnf uses fmt.Sprintf to log a templated message.

func Warnw

func Warnw(msg string, keysAndValues ...interface{})

Warnw logs a message with some additional context, With key and values, example: log.Warnw("message", "url", url, "attempt", 3) Keys in key-value pairs should be strings.

Types

type BaseFields

type BaseFields struct {
	ServiceName string
	Env         string
	CodeVersion string
}

BaseFields represents the base fields for create the basic fields of logger.

type Configuration

type Configuration struct {
	IsJSON     bool
	Level      string
	BaseFields BaseFields
}

Configuration stores the config for the logger For some loggers there can only be one level across writers, for such the level of Console is picked by default

type Logger

type Logger interface {
	Debug(msg string)
	Debugw(msg string, keysAndValues ...interface{})
	Debugf(template string, args ...interface{})

	Info(msg string)
	Infow(msg string, keysAndValues ...interface{})
	Infof(template string, args ...interface{})

	Warn(msg string)
	Warnw(msg string, keysAndValues ...interface{})
	Warnf(template string, args ...interface{})

	Error(msg string)
	Errorw(msg string, keysAndValues ...interface{})
	Errorf(template string, args ...interface{})

	Fatal(msg string)
	Fatalw(msg string, keysAndValues ...interface{})
	Fatalf(template string, args ...interface{})

	Panic(msg string)
	Panicw(msg string, keysAndValues ...interface{})
	Panicf(template string, args ...interface{})
}

Logger is our contract for the logger

Jump to

Keyboard shortcuts

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