log

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: Apache-2.0 Imports: 8 Imported by: 22

README

General framework for log

This is a small project but code I used in each project. I'd like to be independent to a logging framework. That's why I use this to wrap it.

Used log frameworks in the past

  • logrus (github.com/sirupsen/logrus)
  • zap logging (go.uber.org/zap )
  • own logging framework

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Log = LogI(lognil())

Central central configuration

Functions

func InitLog

func InitLog(newLog LogI)

func InitZapLogLevelWithFile added in v0.2.0

func InitZapLogLevelWithFile(fileName string, levelIn zapcore.Level) (err error)

InitZapLogLevelWithFile initializes the zap logger with a file and log level

func InitZapLogLevelWithFilename added in v0.2.0

func InitZapLogLevelWithFilename(fileName string, levelIn zapcore.Level) (err error)

InitZapLogLevelWithFilename initializes the zap logger with a file name and log level

func InitZapLogWithFile added in v0.2.0

func InitZapLogWithFile(name string) (err error)

InitZapLogWithFile initializes the zap logger with a file

func InitZapLogWithFilename added in v0.4.0

func InitZapLogWithFilename(fileName string) (err error)

InitZapLogWithFilename initializes the zap logger with a file name and default log level

func IsDebugLevel

func IsDebugLevel() bool

func LogFunctionEnd added in v0.2.0

func LogFunctionEnd(start time.Time)

LogFunctionEnd log function end if debug is enabled Usage: defer LogFunctionEnd(time.Now())

func LogFunctionEnds added in v0.3.0

func LogFunctionEnds(start time.Time, info string)

LogFunctionEnd log function end if debug is enabled Usage: defer LogFunctionEnd(time.Now())

func LogFunctionStart added in v0.2.0

func LogFunctionStart()

LogFunctionStart log function start if debug is enabled

func LogFunctionStarts added in v0.3.0

func LogFunctionStarts(info string)

LogFunctionStart log function start if debug is enabled

func LogMultiLineString

func LogMultiLineString(debug bool, logOutput string)

LogMultiLineString log multi line string to log. This prevent the \n display in log. Instead multiple lines are written to log

func SetDebugLevel

func SetDebugLevel(debugIn bool)

func TimeTrack

func TimeTrack(start time.Time, name string)

TimeTrack defer function measure the difference end log it to log management, like

defer TimeTrack(time.Now(), "Info")

Types

type LogI

type LogI interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
}

Log defines the log interface to manage other Log output frameworks

Jump to

Keyboard shortcuts

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