gollog

package module
v0.0.0-...-8ca1383 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: MIT Imports: 9 Imported by: 0

README

gollog

few helper/wrapper functions for simplistic level based logging

extracted from an older pandora box of such packages at abhishekkr/gol

Public Functions

  • LogOnce(logfile, level, msg string), can be used without calling Start()

  • Start() error, to be called at init/main before following Log Level functions to be used.

  • Debug(msg string)

  • Debugf(msgTmpl string, param ...interface{})

  • Info(msg string)

  • Infof(msgTmpl string, param ...interface{})

  • Warn(msg string)

  • Warnf(msgTmpl string, param ...interface{})

  • Error(msg string)

  • Errorf(msgTmpl string, param ...interface{})

  • Panic(msg string)

  • Panicf(msgTmpl string, param ...interface{})

Public Variables available to be tuned
  • Level ("Debug", "Info", "Warn", "Error", "Panic")
  • SaveAt (if to be persisted, log file path)
  • Display (if to be printed on display, set to true)
  • Persist (if to be persisted, set to true)

Wrappers

  • SetGinLog(*gin.Engine) to be used for Gin to log json details for requests

Documentation

Index

Constants

View Source
const DefaultLogFile = "default-gollog.log"

Variables

View Source
var (
	Level          string
	Thread         chan GollogMsg
	SaveAt         string
	LogFileHandler *os.File
	Display        bool
	Persist        bool
)
View Source
var (
	GinTimeFormat = time.RFC3339
	GinEnableUTC  = false
)
View Source
var (
	LevelPriority = map[GollogLevel]uint8{
		LevelDebug:   0,
		LevelInfo:    1,
		LevelWarning: 2,
		LevelError:   3,
		LevelPanic:   4,
	}
)

Functions

func Debug

func Debug(msg string)

func Debugf

func Debugf(msgTmpl string, param ...interface{})

func Error

func Error(msg string)

func Errorf

func Errorf(msgTmpl string, param ...interface{})

func Info

func Info(msg string)

func Infof

func Infof(msgTmpl string, param ...interface{})

func LogIt

func LogIt()

func LogOnce

func LogOnce(logfile, level, msg string)

Open, Log, Close

func Panic

func Panic(msg string)

func Panicf

func Panicf(msgTmpl string, param ...interface{})

func SetGinLog

func SetGinLog(router *gin.Engine)

func Start

func Start(proc func())

start Log Action

func Stop

func Stop()

func Warn

func Warn(msg string)

func Warnf

func Warnf(msgTmpl string, param ...interface{})

Types

type GollogLevel

type GollogLevel string
const (
	LevelDebug   GollogLevel = "DEBUG"
	LevelInfo    GollogLevel = "INFO"
	LevelWarning GollogLevel = "WARN"
	LevelError   GollogLevel = "ERROR"
	LevelPanic   GollogLevel = "PANIC"
)

type GollogMsg

type GollogMsg struct {
	Level GollogLevel
	Msg   interface{}
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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