logger

package
v0.0.0-...-7fd01df Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackendSysLogWriter

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

BackendSysLogWriter a syslog writer to write the log to syslog in background

func NewBackendSysLogWriter

func NewBackendSysLogWriter(network, raddr string, priority syslog.Priority, tag string) *BackendSysLogWriter

NewBackendSysLogWriter creates background syslog writer

func (*BackendSysLogWriter) Close

func (bs *BackendSysLogWriter) Close() error

Close background write channel

func (*BackendSysLogWriter) Write

func (bs *BackendSysLogWriter) Write(b []byte) (int, error)

Write data to the backend syslog writer

type BackgroundWriteCloser

type BackgroundWriteCloser struct {
	io.WriteCloser
	// contains filtered or unexported fields
}

BackgroundWriteCloser write data in background

func NewBackgroundWriteCloser

func NewBackgroundWriteCloser(writeCloser io.WriteCloser) *BackgroundWriteCloser

NewBackgroundWriteCloser creates new BackgroundWriteCloser object

func (*BackgroundWriteCloser) Close

func (bw *BackgroundWriteCloser) Close() error

Close background data channel

func (*BackgroundWriteCloser) Write

func (bw *BackgroundWriteCloser) Write(p []byte) (n int, err error)

Write data in background

type ChanLogger

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

ChanLogger write log message by channel

func NewChanLogger

func NewChanLogger(channel chan []byte) *ChanLogger

NewChanLogger creates ChanLogger object

func (*ChanLogger) ClearAllLogFile

func (l *ChanLogger) ClearAllLogFile() error

ClearAllLogFile returns error for ChanLogger

func (*ChanLogger) ClearCurLogFile

func (l *ChanLogger) ClearCurLogFile() error

ClearCurLogFile returns error for ChanLogger

func (*ChanLogger) Close

func (l *ChanLogger) Close() error

Close ChanLogger

func (*ChanLogger) ReadLog

func (l *ChanLogger) ReadLog(offset int64, length int64) (string, error)

ReadLog returns error for ChanLogger

func (*ChanLogger) ReadTailLog

func (l *ChanLogger) ReadTailLog(offset int64, length int64) (string, int64, bool, error)

ReadTailLog returns error for ChanLogger

func (*ChanLogger) SetPid

func (l *ChanLogger) SetPid(pid int)

SetPid sets program pid

func (*ChanLogger) Write

func (l *ChanLogger) Write(p []byte) (int, error)

Write log to the channel

type CompositeLogger

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

CompositeLogger dispatch the log message to other loggers

func NewCompositeLogger

func NewCompositeLogger(loggers []Logger) *CompositeLogger

NewCompositeLogger creates new CompositeLogger object (pool of loggers)

func (*CompositeLogger) AddLogger

func (cl *CompositeLogger) AddLogger(logger Logger)

AddLogger adds logger to CompositeLogger pool

func (*CompositeLogger) ClearAllLogFile

func (cl *CompositeLogger) ClearAllLogFile() error

ClearAllLogFile clear all the files of first logger in CompositeLogger pool

func (*CompositeLogger) ClearCurLogFile

func (cl *CompositeLogger) ClearCurLogFile() error

ClearCurLogFile clear the first logger file in CompositeLogger pool

func (*CompositeLogger) Close

func (cl *CompositeLogger) Close() (err error)

Close all loggers in CompositeLogger pool

func (*CompositeLogger) ReadLog

func (cl *CompositeLogger) ReadLog(offset int64, length int64) (string, error)

ReadLog read log data from first logger in CompositeLogger pool

func (*CompositeLogger) ReadTailLog

func (cl *CompositeLogger) ReadTailLog(offset int64, length int64) (string, int64, bool, error)

ReadTailLog tail the log data from first logger in CompositeLogger pool

func (*CompositeLogger) RemoveLogger

func (cl *CompositeLogger) RemoveLogger(logger Logger)

RemoveLogger removes logger from CompositeLogger pool

func (*CompositeLogger) SetPid

func (cl *CompositeLogger) SetPid(pid int)

SetPid sets pid to all loggers in CompositeLogger pool

func (*CompositeLogger) Write

func (cl *CompositeLogger) Write(p []byte) (n int, err error)

Write dispatches log data to the loggers in CompositeLogger pool

type FileLogger

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

FileLogger log program stdout/stderr to file

func NewFileLogger

func NewFileLogger(name string, maxSize int64, backups int, logEventEmitter LogEventEmitter, locker sync.Locker) *FileLogger

NewFileLogger creates FileLogger object

func (*FileLogger) ClearAllLogFile

func (l *FileLogger) ClearAllLogFile() error

ClearAllLogFile clears contents of all log files (re-open with truncate)

func (*FileLogger) ClearCurLogFile

func (l *FileLogger) ClearCurLogFile() error

ClearCurLogFile clears contents (re-open with truncate) of current log file

func (*FileLogger) Close

func (l *FileLogger) Close() error

Close file logger

func (*FileLogger) ReadLog

func (l *FileLogger) ReadLog(offset int64, length int64) (string, error)

ReadLog reads log from current logfile

func (*FileLogger) ReadTailLog

func (l *FileLogger) ReadTailLog(offset int64, length int64) (string, int64, bool, error)

ReadTailLog tails current log file

func (*FileLogger) SetPid

func (l *FileLogger) SetPid(pid int)

SetPid sets pid of the program

func (*FileLogger) Write

func (l *FileLogger) Write(p []byte) (int, error)

Write overrides function in io.Writer. Write log message to the file

type LogCaptureLogger

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

LogCaptureLogger capture the log for further analysis

func NewLogCaptureLogger

func NewLogCaptureLogger(underlineLogger Logger,
	captureMaxBytes int,
	stdType string,
	procName string,
	groupName string) *LogCaptureLogger

NewLogCaptureLogger creates new LogCaptureLogger object

func (*LogCaptureLogger) ClearAllLogFile

func (l *LogCaptureLogger) ClearAllLogFile() error

ClearAllLogFile clears all log files

func (*LogCaptureLogger) ClearCurLogFile

func (l *LogCaptureLogger) ClearCurLogFile() error

ClearCurLogFile clears current log file

func (*LogCaptureLogger) Close

func (l *LogCaptureLogger) Close() error

Close LogCaptureLogger

func (*LogCaptureLogger) ReadLog

func (l *LogCaptureLogger) ReadLog(offset int64, length int64) (string, error)

ReadLog reads log from LogCaptureLogger

func (*LogCaptureLogger) ReadTailLog

func (l *LogCaptureLogger) ReadTailLog(offset int64, length int64) (string, int64, bool, error)

ReadTailLog tails log from LogCaptureLogger

func (*LogCaptureLogger) SetPid

func (l *LogCaptureLogger) SetPid(pid int)

SetPid sets pid of program

func (*LogCaptureLogger) Write

func (l *LogCaptureLogger) Write(p []byte) (int, error)

Write log to LogCaptureLogger

type LogEventEmitter

type LogEventEmitter interface {
	// contains filtered or unexported methods
}

LogEventEmitter the interface to emit log events

type Logger

type Logger interface {
	io.WriteCloser
	SetPid(pid int)
	ReadLog(offset int64, length int64) (string, error)
	ReadTailLog(offset int64, length int64) (string, int64, bool, error)
	ClearCurLogFile() error
	ClearAllLogFile() error
}

Logger the log interface to log program stdout/stderr logs to file

func NewLogger

func NewLogger(programName string, logFile string, locker sync.Locker, maxBytes int64, backups int, props map[string]string, logEventEmitter LogEventEmitter) Logger

NewLogger creates logger for a program with parameters

type NullLocker

type NullLocker struct {
}

NullLocker no lock

func NewNullLocker

func NewNullLocker() *NullLocker

NewNullLocker creates new NullLocker object

func (*NullLocker) Lock

func (l *NullLocker) Lock()

Lock is a stub function for NullLocker

func (*NullLocker) Unlock

func (l *NullLocker) Unlock()

Unlock is a stub function for NullLocker

type NullLogEventEmitter

type NullLogEventEmitter struct {
}

NullLogEventEmitter will not emit log to any listener

func NewNullLogEventEmitter

func NewNullLogEventEmitter() *NullLogEventEmitter

NewNullLogEventEmitter creates new NullLogEventEmitter object

type NullLogger

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

NullLogger discard the program stdout/stderr log

func NewNullLogger

func NewNullLogger(logEventEmitter LogEventEmitter) *NullLogger

NewNullLogger creates NullLogger object

func (*NullLogger) ClearAllLogFile

func (l *NullLogger) ClearAllLogFile() error

ClearAllLogFile returns error for NullLogger

func (*NullLogger) ClearCurLogFile

func (l *NullLogger) ClearCurLogFile() error

ClearCurLogFile returns error for NullLogger

func (*NullLogger) Close

func (l *NullLogger) Close() error

Close the NullLogger

func (*NullLogger) ReadLog

func (l *NullLogger) ReadLog(offset int64, length int64) (string, error)

ReadLog returns error for NullLogger

func (*NullLogger) ReadTailLog

func (l *NullLogger) ReadTailLog(offset int64, length int64) (string, int64, bool, error)

ReadTailLog returns error for NullLogger

func (*NullLogger) SetPid

func (l *NullLogger) SetPid(pid int)

SetPid sets pid of program

func (*NullLogger) Write

func (l *NullLogger) Write(p []byte) (int, error)

Write log to NullLogger

type StdLogEventEmitter

type StdLogEventEmitter struct {
	Type string
	// contains filtered or unexported fields
}

StdLogEventEmitter emit the Stdout/Stderr LogEvent

func NewStderrLogEventEmitter

func NewStderrLogEventEmitter(processName string, groupName string, procPidFunc func() int) *StdLogEventEmitter

NewStderrLogEventEmitter creates new StdLogEventEmitter object for emitting Stderr log events

func NewStdoutLogEventEmitter

func NewStdoutLogEventEmitter(processName string, groupName string, procPidFunc func() int) *StdLogEventEmitter

NewStdoutLogEventEmitter creates new StdLogEventEmitter object

type StdLogger

type StdLogger struct {
	NullLogger
	// contains filtered or unexported fields
}

StdLogger stdout/stderr logger implementation

func NewStderrLogger

func NewStderrLogger(logEventEmitter LogEventEmitter) *StdLogger

NewStderrLogger creates stderr logger

func NewStdoutLogger

func NewStdoutLogger(logEventEmitter LogEventEmitter) *StdLogger

NewStdoutLogger creates StdLogger object

func (*StdLogger) Write

func (l *StdLogger) Write(p []byte) (int, error)

Write output to stdout/stderr

type SysLogger

type SysLogger struct {
	NullLogger
	// contains filtered or unexported fields
}

SysLogger log program stdout/stderr to syslog

func NewRemoteSysLogger

func NewRemoteSysLogger(name string, config string, props map[string]string, logEventEmitter LogEventEmitter) *SysLogger

NewRemoteSysLogger creates network syslog logger object

func NewSysLogger

func NewSysLogger(name string, props map[string]string, logEventEmitter LogEventEmitter) *SysLogger

NewSysLogger creates local syslog

func (*SysLogger) Close

func (sl *SysLogger) Close() error

Close (sys)logger

func (*SysLogger) Write

func (sl *SysLogger) Write(b []byte) (int, error)

Write log to syslog

Jump to

Keyboard shortcuts

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