zlog

package module
v0.0.0-...-eae9525 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: CC0-1.0 Imports: 10 Imported by: 0

README

zero log (zlog)

fully featured logging library in go.

features

  • 0 deps.
  • minimal code (292 lines of code).
  • extremely simple to use.

usage

zlog.Warn("best logging library :D")

license

this project is released under CC0 1.0 public domain with an additional IP waiver. do whatever you want with it. no rights reserved.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string)

func Debugf

func Debugf(f string, a ...any)

func Debugw

func Debugw(msg string, f F, a ...any)

func EnableColors

func EnableColors(on bool)

func EnableTimestamps

func EnableTimestamps(on bool)

func Error

func Error(msg string)

func Errorf

func Errorf(f string, a ...any)

func Errorw

func Errorw(msg string, f F, a ...any)

func Fatal

func Fatal(msg string)

func Fatalf

func Fatalf(f string, a ...any)

func Fatalw

func Fatalw(msg string, f F, a ...any)

func Info

func Info(msg string)

func Infof

func Infof(f string, a ...any)

func Infow

func Infow(msg string, f F, a ...any)

func SetJSON

func SetJSON(on bool)

func SetLevel

func SetLevel(l Level)

func SetOutput

func SetOutput(w io.Writer)

Std shortcuts

func SetTimeFormat

func SetTimeFormat(tf string)

func ShowCaller

func ShowCaller(on bool)

func Warn

func Warn(msg string)

func Warnf

func Warnf(f string, a ...any)

func Warnw

func Warnw(msg string, f F, a ...any)

Types

type F

type F map[string]any

type Level

type Level int
const (
	LevelDebug Level = iota
	LevelInfo
	LevelWarn
	LevelError
	LevelFatal
)

func ParseLevel

func ParseLevel(s string) (Level, error)

func (Level) String

func (l Level) String() string

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func New

func New() *Logger

func WithFields

func WithFields(f F) *Logger

func (*Logger) Debug

func (l *Logger) Debug(msg string)

Convenience methods

func (*Logger) Debugf

func (l *Logger) Debugf(f string, a ...any)

func (*Logger) Debugw

func (l *Logger) Debugw(msg string, f F, a ...any)

func (*Logger) EnableColors

func (l *Logger) EnableColors(on bool)

func (*Logger) EnableTimestamps

func (l *Logger) EnableTimestamps(on bool)

func (*Logger) Error

func (l *Logger) Error(msg string)

func (*Logger) Errorf

func (l *Logger) Errorf(f string, a ...any)

func (*Logger) Errorw

func (l *Logger) Errorw(msg string, f F, a ...any)

func (*Logger) Fatal

func (l *Logger) Fatal(msg string)

func (*Logger) Fatalf

func (l *Logger) Fatalf(f string, a ...any)

func (*Logger) Fatalw

func (l *Logger) Fatalw(msg string, f F, a ...any)

func (*Logger) Info

func (l *Logger) Info(msg string)

func (*Logger) Infof

func (l *Logger) Infof(f string, a ...any)

func (*Logger) Infow

func (l *Logger) Infow(msg string, f F, a ...any)

func (*Logger) Log

func (l *Logger) Log(level Level, msg string, extra F)

func (*Logger) SetJSON

func (l *Logger) SetJSON(on bool)

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

func (*Logger) SetLevelBgColor

func (l *Logger) SetLevelBgColor(level Level, bg string)

func (*Logger) SetLevelColor

func (l *Logger) SetLevelColor(level Level, fg string)

Custom colors

func (*Logger) SetOutput

func (l *Logger) SetOutput(w io.Writer)

Config

func (*Logger) SetTimeFormat

func (l *Logger) SetTimeFormat(tf string)

func (*Logger) ShowCaller

func (l *Logger) ShowCaller(on bool)

func (*Logger) Warn

func (l *Logger) Warn(msg string)

func (*Logger) Warnf

func (l *Logger) Warnf(f string, a ...any)

func (*Logger) Warnw

func (l *Logger) Warnw(msg string, f F, a ...any)

func (*Logger) WithFields

func (l *Logger) WithFields(f F) *Logger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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