log

package module
v0.0.0-...-70c8d51 Latest Latest
Warning

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

Go to latest
Published: May 26, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

README

GoLog

Simplistic golang log package.

Functions

func SetLevel(lvl Level)
func SetPath(p string) // set path to log dir for logging to file

func EnableLogToFile()
func DisableLogToFile()
func EnableLogToMsg()
func DisableLogToMsg()

func Debug(format string, args ...any) Log
func Info(format string, args ...any) Log
func Warn(format string, args ...any) Log
func Error(format string, args ...any) Log
func Fatal(format string, args ...any) Log

func (l Log) Msg() // log to stdout/stderr
func (l Log) File() // log to file
func (l Log) Full() // log to stdout/stderr then file (if allowed)

Info

  • Log functions will format string with args such as fmt.Printf in every case except below
  • If the last argument to a log function is of type log.Params (map[string]any) the output will format log.Params and append it to the log message, see example below
log.Debug("Hello, %s", "World", log.Params{"time": "3pm", "afternoon": true}).Msg()

example_1

Documentation

Index

Constants

View Source
const (
	LevelDebug = iota
	LevelInfo
	LevelWarn
	LevelError
	LevelFatal
)

Variables

This section is empty.

Functions

func DisableLogToFile

func DisableLogToFile()

func DisableLogToMsg

func DisableLogToMsg()

func EnableLogToFile

func EnableLogToFile()

func EnableLogToMsg

func EnableLogToMsg()

func SetLevel

func SetLevel(lvl Level)

func SetPath

func SetPath(p string)

Types

type Level

type Level uint32

type Log

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

func Debug

func Debug(format string, args ...any) Log

func Error

func Error(format string, args ...any) Log

func Fatal

func Fatal(format string, args ...any) Log

func Info

func Info(format string, args ...any) Log

func Warn

func Warn(format string, args ...any) Log

func (Log) File

func (l Log) File()

func (Log) Full

func (l Log) Full()

func (Log) Msg

func (l Log) Msg()

type Params

type Params map[string]any

Jump to

Keyboard shortcuts

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