log

package
v0.0.0-...-d161ec2 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package log is used to initialize logger

Package log is used to initialize the logger.

Package log is used to initialize the logger.

Package log is used to initialize the logger.

Package log is used to initialize logger

Package log is used to initialize the logger.

Package log is used to initialize the logger.

Index

Constants

View Source
const (
	LogFileExtension     = ".log"
	SeelogConfigFileName = "seelog.xml"
	ErrorLogFileSuffix   = "errors"
)
View Source
const (
	LogsDirectory                = "logs"
	DefaultInstallLocationPrefix = "/usr/local"
)

Variables

View Source
var (
	DefaultSeelogConfigFilePath string // DefaultSeelogConfigFilePath specifies the default seelog location
	DefaultLogDir               string // DefaultLogDir specifies default log location
	ApplicationLogFile          string // ApplicationLogFile specifies name of application log file
	ErrorLogFile                string // ErrorLogFile specifies name of error log file

)

Functions

func DefaultConfig

func DefaultConfig() []byte

func LoadLog

func LoadLog(defaultLogDir string, logFile string, errorFile string) []byte

Types

type BasicT

type BasicT interface {
	// Tracef formats message according to format specifier
	// and writes to log with level Trace.
	Tracef(format string, params ...interface{})

	// Debugf formats message according to format specifier
	// and writes to log with level Debug.
	Debugf(format string, params ...interface{})

	// Infof formats message according to format specifier
	// and writes to log with level Info.
	Infof(format string, params ...interface{})

	// Warnf formats message according to format specifier
	// and writes to log with level Warn.
	Warnf(format string, params ...interface{}) error

	// Errorf formats message according to format specifier
	// and writes to log with level Error.
	Errorf(format string, params ...interface{}) error

	// Criticalf formats message according to format specifier
	// and writes to log with level Critical.
	Criticalf(format string, params ...interface{}) error

	// Trace formats message using the default formats for its operands
	// and writes to log with level Trace.
	Trace(v ...interface{})

	// Debug formats message using the default formats for its operands
	// and writes to log with level Debug.
	Debug(v ...interface{})

	// Info formats message using the default formats for its operands
	// and writes to log with level Info.
	Info(v ...interface{})

	// Warn formats message using the default formats for its operands
	// and writes to log with level Warn.
	Warn(v ...interface{}) error

	// Error formats message using the default formats for its operands
	// and writes to log with level Error.
	Error(v ...interface{}) error

	// Critical formats message using the default formats for its operands
	// and writes to log with level Critical.
	Critical(v ...interface{}) error

	// Flush flushes all the messages in the logger.
	Flush()

	// Close flushes all the messages in the logger and closes it. The logger cannot be used after this operation.
	Close()
}

BasicT represents structs capable of logging messages. This interface matches seelog.LoggerInterface.

type ContextFormatFilter

type ContextFormatFilter struct {
	Context []string
}

ContextFormatFilter is a filter that can add a context to the parameters of a log message.

func (ContextFormatFilter) Filter

func (f ContextFormatFilter) Filter(params ...interface{}) (newParams []interface{})

Filter adds the context at the beginning of the parameter slice.

func (ContextFormatFilter) Filterf

func (f ContextFormatFilter) Filterf(format string, params ...interface{}) (newFormat string, newParams []interface{})

Filterf adds the context in from of the format string.

type DelegateLogger

type DelegateLogger struct {
	BaseLoggerInstance BasicT
}

DelegateLogger holds the base logger for logging

type FileWatcher

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

FileWatcher implements the IFileWatcher by using fileChangeWatcher and fileExistsWatcher

func (*FileWatcher) Init

func (fileWatcher *FileWatcher) Init(log T, configFilePath string, replaceLogger func())

Init initializes the data and channels for the filewatcher

func (*FileWatcher) Start

func (fileWatcher *FileWatcher) Start()

Start creates and starts the go routines for filewatcher

func (*FileWatcher) Stop

func (fileWatcher *FileWatcher) Stop()

Stop stops the filewatcher

type FormatFilter

type FormatFilter interface {

	// Filter modifies parameters that will be passed to log.Debug, log.Info, etc.
	Filter(params ...interface{}) (newParams []interface{})

	// Filter modifies format and/or parameter strings that will be passed to log.Debugf, log.Infof, etc.
	Filterf(format string, params ...interface{}) (newFormat string, newParams []interface{})
}

FormatFilter can modify the format and or parameters to be passed to a logger.

type IFileWatcher

type IFileWatcher interface {
	Init(log T, configFilePath string, replaceLogger func())
	Start()
	Stop()
}

IFileWatcher interface for FileWatcher with functions to initialize, start and stop the watcher

type LogConfig

type LogConfig struct {
	ClientName string
}

func (*LogConfig) GetLogConfigBytes

func (config *LogConfig) GetLogConfigBytes() []byte

func (*LogConfig) InitLogger

func (config *LogConfig) InitLogger(useWatcher bool) (logger T)

initLogger initializes a new logger based on current configurations and starts file watcher on the configurations file

type Mock

type Mock struct {
	mock.Mock
	// contains filtered or unexported fields
}

Mock stands for a mocked log.

func NewMockLog

func NewMockLog() *Mock

NewMockLogger returns an instance of Mock with default expectations set.

func NewMockLogWithContext

func NewMockLogWithContext(ctx string) *Mock

func (*Mock) Close

func (_m *Mock) Close()

Close mocks the Close function.

func (*Mock) Critical

func (_m *Mock) Critical(v ...interface{}) error

Critical mocks the Critical function.

func (*Mock) Criticalf

func (_m *Mock) Criticalf(format string, params ...interface{}) error

Criticalf mocks the Criticalf function.

func (*Mock) Debug

func (_m *Mock) Debug(v ...interface{})

Debug mocks the Debug function.

func (*Mock) Debugf

func (_m *Mock) Debugf(format string, params ...interface{})

Debugf mocks the Debugf function.

func (*Mock) Error

func (_m *Mock) Error(v ...interface{}) error

Error mocks the Error function.

func (*Mock) Errorf

func (_m *Mock) Errorf(format string, params ...interface{}) error

Errorf mocks the Errorf function.

func (*Mock) Flush

func (_m *Mock) Flush()

Flush mocks the Flush function.

func (*Mock) Info

func (_m *Mock) Info(v ...interface{})

Info mocks the Info function.

func (*Mock) Infof

func (_m *Mock) Infof(format string, params ...interface{})

Infof mocks the Infof function.

func (*Mock) Trace

func (_m *Mock) Trace(v ...interface{})

Trace mocks the Trace function.

func (*Mock) Tracef

func (_m *Mock) Tracef(format string, params ...interface{})

Tracef mocks the Tracef function.

func (*Mock) Warn

func (_m *Mock) Warn(v ...interface{}) error

Warn mocks the Warn function.

func (*Mock) Warnf

func (_m *Mock) Warnf(format string, params ...interface{}) error

Warnf mocks the Warnf function.

func (*Mock) WithContext

func (_m *Mock) WithContext(context ...string) (contextLogger T)

type T

type T interface {
	BasicT
	WithContext(context ...string) (contextLogger T)
}

T represents structs capable of logging messages, and context management.

func Logger

func Logger(useWatcher bool, clientName string) T

Logger is the starting point to initialize with client name.

type Wrapper

type Wrapper struct {
	Format   FormatFilter
	M        *sync.Mutex
	Delegate *DelegateLogger
}

Wrapper is a logger that can modify the format of a log message before delegating to another logger.

func (*Wrapper) Close

func (w *Wrapper) Close()

Close flushes all the messages in the logger and closes it. It cannot be used after this operation.

func (*Wrapper) Critical

func (w *Wrapper) Critical(v ...interface{}) error

Critical formats message using the default formats for its operands and writes to log with level = Critical

func (*Wrapper) Criticalf

func (w *Wrapper) Criticalf(format string, params ...interface{}) error

Criticalf formats message according to format specifier and writes to log with level = Critical.

func (*Wrapper) Debug

func (w *Wrapper) Debug(v ...interface{})

Debug formats message using the default formats for its operands and writes to log with level = Debug

func (*Wrapper) Debugf

func (w *Wrapper) Debugf(format string, params ...interface{})

Debugf formats message according to format specifier and writes to log with level = Debug.

func (*Wrapper) Error

func (w *Wrapper) Error(v ...interface{}) error

Error formats message using the default formats for its operands and writes to log with level = Error

func (*Wrapper) Errorf

func (w *Wrapper) Errorf(format string, params ...interface{}) error

Errorf formats message according to format specifier and writes to log with level = Error.

func (*Wrapper) Flush

func (w *Wrapper) Flush()

Flush flushes all the messages in the logger.

func (*Wrapper) Info

func (w *Wrapper) Info(v ...interface{})

Info formats message using the default formats for its operands and writes to log with level = Info

func (*Wrapper) Infof

func (w *Wrapper) Infof(format string, params ...interface{})

Infof formats message according to format specifier and writes to log with level = Info.

func (*Wrapper) ReplaceDelegate

func (w *Wrapper) ReplaceDelegate(newLogger BasicT)

ReplaceDelegate replaces the delegate logger with a new logger

func (*Wrapper) Trace

func (w *Wrapper) Trace(v ...interface{})

Trace formats message using the default formats for its operands and writes to log with level = Trace

func (*Wrapper) Tracef

func (w *Wrapper) Tracef(format string, params ...interface{})

Tracef formats message according to format specifier and writes to log with level = Trace.

func (*Wrapper) Warn

func (w *Wrapper) Warn(v ...interface{}) error

Warn formats message using the default formats for its operands and writes to log with level = Warn

func (*Wrapper) Warnf

func (w *Wrapper) Warnf(format string, params ...interface{}) error

Warnf formats message according to format specifier and writes to log with level = Warn.

func (*Wrapper) WithContext

func (w *Wrapper) WithContext(context ...string) (contextLogger T)

WithContext creates a wrapper logger with context

Jump to

Keyboard shortcuts

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