log

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2025 License: Apache-2.0 Imports: 5 Imported by: 1

README

about

This is a simple wrapper for logging libraries used in some of my projects

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Key       string
	Type      FieldType
	Integer   int64
	String    string
	Interface interface{}
}

Field represents a key-value pair for structured logging. It wraps zap.Field internally but provides a zap-independent interface.

func Any

func Any(key string, val interface{}) Field

func Bool

func Bool(key string, val bool) Field

func ByteString

func ByteString(key string, val []byte) Field

func Duration

func Duration(key string, val time.Duration) Field

func Error

func Error(err error) Field

func Float32

func Float32(key string, val float32) Field

func Float64

func Float64(key string, val float64) Field

func Int

func Int(key string, val int) Field

func Int16

func Int16(key string, val int16) Field

func Int32

func Int32(key string, val int32) Field

func Int64

func Int64(key string, val int64) Field

func Int8

func Int8(key string, val int8) Field

func String

func String(key string, val string) Field

func Stringer

func Stringer(key string, val fmt.Stringer) Field

func Time

func Time(key string, val time.Time) Field

func Uint

func Uint(key string, val uint) Field

func Uint16

func Uint16(key string, val uint16) Field

func Uint32

func Uint32(key string, val uint32) Field

func Uint64

func Uint64(key string, val uint64) Field

func Uint8

func Uint8(key string, val uint8) Field

type FieldType

type FieldType uint8

FieldType represents the type of a field.

const (
	UnknownType FieldType = iota
	StringType
	Int64Type
	IntType
	Int32Type
	Int16Type
	Int8Type
	Uint64Type
	Uint32Type
	Uint16Type
	Uint8Type
	UintType
	Float64Type
	Float32Type
	BoolType
	ErrorType
	DurationType
	TimeType
	ByteStringType
	StringerType
	AnyType
)

type Logger

type Logger interface {
	Debug(msg string, fields ...Field)
	Info(msg string, fields ...Field)
	Warn(msg string, fields ...Field)
	Error(msg string, fields ...Field)
	Panic(msg string, fields ...Field)
	Fatal(msg string, fields ...Field)

	// Sugar returns a sugared logger for printf-style APIs
	Sugar() SugaredLogger
}

Logger is the interface that wraps the basic logging methods. It is designed to be a drop-in replacement for *zap.Logger.

func GetLogger

func GetLogger(level LoggingLevel,
	disableLogToConsole bool, filename string) (Logger, error)

func MustGetTestLogger

func MustGetTestLogger() Logger

func NewZapAdapter

func NewZapAdapter(logger *zap.Logger) Logger

NewZapAdapter creates a new Logger that wraps the given *zap.Logger.

type LoggingLevel

type LoggingLevel uint64
const (
	Production LoggingLevel = iota
	Development
)

type SugaredLogger

type SugaredLogger interface {
	Panicf(template string, args ...interface{})
}

SugaredLogger provides a more ergonomic, printf-style API.

Jump to

Keyboard shortcuts

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