hllogger

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: MIT Imports: 4 Imported by: 6 modules, 10 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

HighLevelLogger

GoDoc

Enhances the Golang default logger by adding facilities wrappers as Debug, Info, Warning, Error and Fatal.

Please check the documentation.

Documentation

Index

Constants

View Source
const (
	Ldate         = log.Ldate
	Ltime         = log.Ltime
	Lmicroseconds = log.Lmicroseconds
	Llongfile     = log.Llongfile
	Lshortfile    = log.Lshortfile
	LUTC          = log.LUTC
	LstdFlags     = log.LstdFlags
)

Forwarders to the log package flags

View Source
const (
	// SystemdDebugPrefix is the string to prefix in Debug for systemd-journald
	SystemdDebugPrefix = "<7>"
	// SystemdInfoPrefix is the string to prefix in Info for systemd-journald
	SystemdInfoPrefix = "<6>"
	// SystemdNoticePrefix is the string to prefix in Notice for systemd-journald
	SystemdNoticePrefix = "<5>"
	// SystemdWarningPrefix is the string to prefix in Warning for systemd-journald
	SystemdWarningPrefix = "<4>"
	// SystemdErrPrefix is the string to prefix in Error for systemd-journald
	SystemdErrPrefix = "<3>"
	// SystemdCritPrefix is the string to prefix in Critical for systemd-journald
	SystemdCritPrefix = "<2>"
	// SystemdAlertPrefix is the string to prefix in Alert for systemd-journald
	SystemdAlertPrefix = "<1>"
	// SystemdEmergPrefix is the string to prefix in Emergency for systemd-journald
	SystemdEmergPrefix = "<0>"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	LogLevel              LogLevel
	LoggerFlags           int
	SystemdJournaldCompat bool
}

Config allows to configure an hllogger

type HlLogger

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

HlLogger is a wrapper around the log/logger

func New

func New(output io.Writer, c *Config) *HlLogger

New is the constructor for a HlLogger object

func (*HlLogger) Debug

func (l *HlLogger) Debug(message string)

Debug is a wrapper to Output()

func (*HlLogger) Debugf

func (l *HlLogger) Debugf(format string, a ...interface{})

Debugf is a wrapper to Debug() adding formating support

func (*HlLogger) Error

func (l *HlLogger) Error(message string)

Error is a wrapper to Output()

func (*HlLogger) Errorf

func (l *HlLogger) Errorf(format string, a ...interface{})

Errorf is a wrapper to Error() adding formating support

func (*HlLogger) Fatal

func (l *HlLogger) Fatal(exitCode int, message string)

Fatal is a wrapper to Output() It will also print the message on stderr and exit with error code 1

func (*HlLogger) Fatalf

func (l *HlLogger) Fatalf(exitCode int, format string, a ...interface{})

Fatalf is a wrapper to Fatal() adding formating support

func (*HlLogger) Info

func (l *HlLogger) Info(message string)

Info is a wrapper to Output()

func (*HlLogger) Infof

func (l *HlLogger) Infof(format string, a ...interface{})

Infof is a wrapper to Info() adding formating support

func (*HlLogger) IsDebugShown

func (l *HlLogger) IsDebugShown() (shown bool)

IsDebugShown returns true if the Debug level is in use

func (*HlLogger) IsErrorShown

func (l *HlLogger) IsErrorShown() (shown bool)

IsErrorShown returns true if the Error level is in use

func (*HlLogger) IsFatalShown

func (l *HlLogger) IsFatalShown() (shown bool)

IsFatalShown returns true if the Fatal level is in use

func (*HlLogger) IsInfoShown

func (l *HlLogger) IsInfoShown() (shown bool)

IsInfoShown returns true if the Info level is in use

func (*HlLogger) IsWarningShown

func (l *HlLogger) IsWarningShown() (shown bool)

IsWarningShown returns true if the Warning level is in use

func (*HlLogger) Output

func (l *HlLogger) Output(message string)

Output is a wrapper to the log.Output() base fx

func (*HlLogger) Outputf

func (l *HlLogger) Outputf(format string, a ...interface{})

Outputf is a wrapper to the the Output() fx but with formating support

func (*HlLogger) Warning

func (l *HlLogger) Warning(message string)

Warning is a wrapper to Output()

func (*HlLogger) Warningf

func (l *HlLogger) Warningf(format string, a ...interface{})

Warningf is a wrapper to Warning() adding formating support

type LogLevel

type LogLevel uint8

LogLevel defines logging level constants

const (
	// Fatal level
	Fatal LogLevel = iota
	// Error level
	Error
	// Warning level
	Warning
	// Info level
	Info
	// Debug level
	Debug
)

func (*LogLevel) String

func (ll *LogLevel) String() string

func (*LogLevel) SystemdPrefix

func (ll *LogLevel) SystemdPrefix() string

SystemdPrefix returns the appropriate prefix for systemd-journald

Jump to

Keyboard shortcuts

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