logging2

package
v0.0.0-...-0c93acb Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ILogger

type ILogger interface {
	Debugf(message string, args ...interface{})
	DisableColors()
	EnableColors()
	Errorf(message string, args ...interface{})
	Infof(message string, args ...interface{})
}

ILogger is an interface that describes how a logger should behave

func LogFactory

func LogFactory(logFormat LogFormat, applicationName string, minimumLogLevel LogType) ILogger

LogFactory returns a logger in the required format

func NewJSONLogger

func NewJSONLogger(applicationName string, minimumLogLevel LogType) ILogger

NewJSONLogger returns an instance of an ILogger interface set to the JSON logger format

func NewSimpleLogger

func NewSimpleLogger(applicationName string, minimumLogLevel LogType) ILogger

NewSimpleLogger returns an instance of an ILogger interface set to the simple logger format

type JSONLogger

type JSONLogger struct {
	Logger
}

JSONLogger is a console logger that has a format of `{"applicationName": "{ApplicationName}", "type": "{Type}"", "message": "{Message}"}`

func (*JSONLogger) Debugf

func (logger *JSONLogger) Debugf(message string, args ...interface{})

Debugf writes a formatted debug entry to the log

func (*JSONLogger) DisableColors

func (logger *JSONLogger) DisableColors()

DisableColors turns of console coloring

func (*JSONLogger) EnableColors

func (logger *JSONLogger) EnableColors()

EnableColors turns on console coloring

func (*JSONLogger) Errorf

func (logger *JSONLogger) Errorf(message string, args ...interface{})

Errorf writes a formatted error entry to the log

func (*JSONLogger) Infof

func (logger *JSONLogger) Infof(message string, args ...interface{})

Infof writes a formatted info entry to the log

type LogFormat

type LogFormat int

LogFormat describes how to format log messages

const (
	LOG_FORMAT_SIMPLE LogFormat = iota
	LOG_FORMAT_JSON
)

Constants for the available log formats

func StringToLogFormat

func StringToLogFormat(logFormatName string) LogFormat

StringToLogFormat converts a specified string to a LogFormat. If the string does not match a specific log type the SIMPLE is returned.

func (LogFormat) String

func (format LogFormat) String() string

String returns the friendly name of a specified log format

type LogType

type LogType int

LogType represents a type and level of logging

const (
	NONE LogType = iota
	DEBUG
	INFO
	WARN
	ERROR
	FATAL
)

Constants for the type and levels of logging

func StringToLogType

func StringToLogType(logTypeName string) LogType

StringToLogType converts a specified string to a LogType. If the string does not match a specific log type the NONE is returned.

func (LogType) Color

func (logType LogType) Color() color.Attribute

Color returns the color attribute for this log type

func (LogType) String

func (logType LogType) String() string

String returns the friendly name of a specified log type/level

type Logger

type Logger struct {
	ApplicationName string
	LogLevel        LogType
	LogFormat       LogFormat
	// contains filtered or unexported fields
}

Logger represents the basic instance of a logging object. Other, more specific loggers will use this

type SimpleLogger

type SimpleLogger struct {
	Logger
}

SimpleLogger is a basic console logger that has a format of `{ApplicationName}: {Type} - {Message}`

func (*SimpleLogger) Debugf

func (logger *SimpleLogger) Debugf(message string, args ...interface{})

Debugf writes a formatted debug entry to the log

func (*SimpleLogger) DisableColors

func (logger *SimpleLogger) DisableColors()

DisableColors turns of console coloring

func (*SimpleLogger) EnableColors

func (logger *SimpleLogger) EnableColors()

EnableColors turns on console coloring

func (*SimpleLogger) Errorf

func (logger *SimpleLogger) Errorf(message string, args ...interface{})

Errorf writes a formatted error entry to the log

func (*SimpleLogger) Infof

func (logger *SimpleLogger) Infof(message string, args ...interface{})

Infof writes a formatted info entry to the log

Jump to

Keyboard shortcuts

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