log

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	// Key for a given field
	Key string
	// Type of a given field
	Type FieldType
	// Value of the given field
	Value interface{}
	// optmizations for string & int
	Integer int64
	String  string
}

Field defines a standard Key-Value pair used to populate the value for the logger

func Bool

func Bool(key string, value bool) Field

Bool is a wrapper for boolean values for logging

func Error

func Error(err error) Field

Error is wrapper for error values for logging

func Float

func Float(key string, value float64) Field

Float value is for floating point fields

func Int

func Int(key string, value int) Field

Int wrapper for logging

func Int64

func Int64(key string, value int64) Field

Int64 is a wrapper int64 values for logging

func Reflect

func Reflect(key string, value interface{}) Field

Reflect returns a field for which the value is undetermined

func String

func String(key string, value string) Field

String is logger wrapper for string

type FieldType

type FieldType int

FieldType defines the type for a field

const (
	UNKNOWN FieldType = iota
	BOOL
	INT
	STRING
	ERROR
	FLOAT
)

Field Types supported by Logger

type Logger

type Logger interface {
	// Should also implement default kit.log.Logger interface
	kit_log.Logger

	// Leveled Logging
	Info(string, ...Field)
	Warn(string, ...Field)
	Error(string, ...Field)
	Panic(string, ...Field)
	Fatal(string, ...Field)
	Debug(string, ...Field)

	Infof(string, ...interface{})
	Errorf(string, ...interface{})
	Debugf(string, ...interface{})

	// Flush the logs
	Flush() error

	// Default Fields
	With(...Field) Logger
}

Logger defines standard set of functions supported by logger and used across the Base Package

func NewZapLogger

func NewZapLogger(
	options ...ZapLoggerOption,
) (Logger, error)

NewZapLogger returns a default implementaiton of log.Logger interface using uber/zap as core layer

type ZapLoggerOption

type ZapLoggerOption func(*zapLogger)

func ZapWithAppendedOutput

func ZapWithAppendedOutput(outputs []string) ZapLoggerOption

ZapWithAppendedOutput is option to add additional output to list of existing output destination

func ZapWithEncoding

func ZapWithEncoding(encoding string) ZapLoggerOption

ZapWithEncoding is option to set encoding for zap based logger

func ZapWithLevel

func ZapWithLevel(level string) ZapLoggerOption

ZapWithLevel is option to set level for Zap Based Logger

func ZapWithOutput

func ZapWithOutput(outputs []string) ZapLoggerOption

ZapWithOutput is option to set output paths for zap based logger

Jump to

Keyboard shortcuts

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