logmsg

package module
v0.0.0-...-31459cf Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: MIT Imports: 4 Imported by: 14

README

logmsg

Dynamic log messaging levels for a go application

Allows for a go application to have log messaging that range from debug to critical events. These messages can be dynamically turned on/off (supressed). Allows for including of detailed diagnostic messages in production code and not impact production, but can be turned on when required.

This is just the package to provide the logging. It will be up to the consuming application to implement the appropiate listener to invoke the logmsg.SetLogLevel() method and change the logging level.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Print

func Print(level LogLevel, v ...interface{})

Print(level LogLevel, v...)

Used to print a message - actaully calls a lower level Print (PrintCallbacklevel) to do this

level - log level

v... - Variable data

func PrintCallbacklevel

func PrintCallbacklevel(callback int, level LogLevel, v ...interface{})

PrintCallbacklevel(callback int, level LogLevel, v...)

Used to print a message -

callback - allows the caller to say how far into the code they are so we can skip back
           up the stack to get a more helpful filename/line number
level - log level

v... - Variable data

func SetLogFile

func SetLogFile(name string) bool

SetLogFileName(name string) bool

Sets up writint go a file. If there is already a file opened, that will be close 1st (allowing for file rollover)

name - New name of the logfile.  Will be used relative to where the program is running unless an explicit path name is used

Returns a true|false depending on success.  Up to the caller to abort/panic

func SetLogLevel

func SetLogLevel(level LogLevel)

Types

type LogLevel

type LogLevel int
const (
	Critical LogLevel = 1 + iota
	Error
	Warning
	Info
	Debug01
	Debug02
	Debug03
	LevelEnd
)

Error levels that the user can set

type MyLogMsg

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

internal structure of keep all our stuff

func New

func New(level LogLevel, outputFilename string) *MyLogMsg

New() Allows a users to creat a new instance of logmsg

func (*MyLogMsg) Print

func (l *MyLogMsg) Print(level LogLevel, v ...interface{})

Print(level LogLevel, v...)

Used to print a message - actaully calls a lower level Print (PrintCallbacklevel) to do this

level - log level

v... - Variable data

func (*MyLogMsg) PrintCallbacklevel

func (l *MyLogMsg) PrintCallbacklevel(callback int, level LogLevel, v ...interface{})

PrintCallbacklevel(callback int, level LogLevel, v...)

Used to print a message -

callback - allows the caller to say how far into the code they are so we can skip back
           up the stack to get a more helpful filename/line number
level - log level

v... - Variable data

func (*MyLogMsg) SetLogFile

func (l *MyLogMsg) SetLogFile(name string) bool

SetLogFile(name string) bool

Sets up a log file. If there is already a file opened, that will be close 1st (allowing for file rollover)

name - New name of the logfile.  Will be used relative to where the program is running unless an explicit path name is used

Returns a true|false depending on success.  Up to the caller to abort/panic

func (*MyLogMsg) SetLogLevel

func (l *MyLogMsg) SetLogLevel(level LogLevel)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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