logger

package module
v0.0.0-...-7111dfa Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 10 Imported by: 1

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 create a background running syslog writer

func (*BackendSysLogWriter) Close

func (bs *BackendSysLogWriter) Close() error

Close close the backgroup write channel

func (*BackendSysLogWriter) Write

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

Write 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 create a new BackgroundWriteCloser object

func (*BackgroundWriteCloser) Close

func (bw *BackgroundWriteCloser) Close() error

Close close the background data channel

func (*BackgroundWriteCloser) Write

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

Write 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 create a ChanLogger object

func (*ChanLogger) ClearAllLogFile

func (l *ChanLogger) ClearAllLogFile() error

ClearAllLogFile clear the log, return error

func (*ChanLogger) ClearCurLogFile

func (l *ChanLogger) ClearCurLogFile() error

ClearCurLogFile clear the log, return error

func (*ChanLogger) Close

func (l *ChanLogger) Close() error

Close close the channel

func (*ChanLogger) ReadLog

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

ReadLog read log, return error

func (*ChanLogger) ReadTailLog

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

ReadTailLog tail the log, return error

func (*ChanLogger) SetPid

func (l *ChanLogger) SetPid(pid int)

SetPid set the program pid

func (*ChanLogger) Write

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

Write write the log to 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 create a new CompositeLogger object

func (*CompositeLogger) AddLogger

func (cl *CompositeLogger) AddLogger(logger Logger)

AddLogger add a logger to receive the log data

func (*CompositeLogger) ClearAllLogFile

func (cl *CompositeLogger) ClearAllLogFile() error

ClearAllLogFile clear all the files of first logger

func (*CompositeLogger) ClearCurLogFile

func (cl *CompositeLogger) ClearCurLogFile() error

ClearCurLogFile clear the first logger file

func (*CompositeLogger) Close

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

Close close all the loggers added by AddLogger() call

func (*CompositeLogger) ReadLog

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

ReadLog read log data from first logger

func (*CompositeLogger) ReadTailLog

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

ReadTailLog tail the log data from first logger

func (*CompositeLogger) RemoveLogger

func (cl *CompositeLogger) RemoveLogger(logger Logger)

RemoveLogger remove the previous added logger

func (*CompositeLogger) SetPid

func (cl *CompositeLogger) SetPid(pid int)

SetPid set pid to all the loggers added by AddLogger() call

func (*CompositeLogger) Write

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

Write dispatch the log data to loggers added by AddLogger() call

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 create a FileLogger object

func (*FileLogger) ClearAllLogFile

func (l *FileLogger) ClearAllLogFile() error

ClearAllLogFile clear all the log files

func (*FileLogger) ClearCurLogFile

func (l *FileLogger) ClearCurLogFile() error

ClearCurLogFile clear the current log file contents

func (*FileLogger) Close

func (l *FileLogger) Close() error

Close close the file logger

func (*FileLogger) ReadLog

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

ReadLog read the log from current logfile

func (*FileLogger) ReadTailLog

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

ReadTailLog tail the log of current log file

func (*FileLogger) SetPid

func (l *FileLogger) SetPid(pid int)

SetPid set the pid of the program

func (*FileLogger) Write

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

Write Override the function in io.Writer. Write the 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 create a new LogCaptureLogger object

func (*LogCaptureLogger) ClearAllLogFile

func (l *LogCaptureLogger) ClearAllLogFile() error

ClearAllLogFile clear all the log files

func (*LogCaptureLogger) ClearCurLogFile

func (l *LogCaptureLogger) ClearCurLogFile() error

ClearCurLogFile clear the current log file

func (*LogCaptureLogger) Close

func (l *LogCaptureLogger) Close() error

Close close the capture

func (*LogCaptureLogger) ReadLog

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

ReadLog read the log

func (*LogCaptureLogger) ReadTailLog

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

ReadTailLog tail the log

func (*LogCaptureLogger) SetPid

func (l *LogCaptureLogger) SetPid(pid int)

SetPid set the pid of program

func (*LogCaptureLogger) Write

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

Write write the log to capture

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, logEventEmitter LogEventEmitter) Logger

NewLogger create a logger for a program with parameters

type NullLocker

type NullLocker struct {
}

NullLocker no lock

func NewNullLocker

func NewNullLocker() *NullLocker

NewNullLocker create a new NullLocker object

func (*NullLocker) Lock

func (l *NullLocker) Lock()

Lock acquire the lock

func (*NullLocker) Unlock

func (l *NullLocker) Unlock()

Unlock release the lock

type NullLogEventEmitter

type NullLogEventEmitter struct {
}

NullLogEventEmitter will not emit log to any listener

func NewNullLogEventEmitter

func NewNullLogEventEmitter() *NullLogEventEmitter

NewNullLogEventEmitter create a 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 create a NullLoger

func (*NullLogger) ClearAllLogFile

func (l *NullLogger) ClearAllLogFile() error

ClearAllLogFile clear all the lof file, return error

func (*NullLogger) ClearCurLogFile

func (l *NullLogger) ClearCurLogFile() error

ClearCurLogFile close current log file, return error

func (*NullLogger) Close

func (l *NullLogger) Close() error

Close close the logger

func (*NullLogger) ReadLog

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

ReadLog read the log, return error

func (*NullLogger) ReadTailLog

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

ReadTailLog tail the log, return error

func (*NullLogger) SetPid

func (l *NullLogger) SetPid(pid int)

SetPid set the pid of program

func (*NullLogger) Write

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

Write write the log to this logger

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 create a new StdLogEventEmitter object for emit the Stderr log

func NewStdoutLogEventEmitter

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

NewStdoutLogEventEmitter create a 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 create a stderr logger

func NewStdoutLogger

func NewStdoutLogger(logEventEmitter LogEventEmitter) *StdLogger

NewStdoutLogger create a StdLogger object

func (*StdLogger) Write

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

Write output the log 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, logEventEmitter LogEventEmitter) *SysLogger

NewRemoteSysLogger create a network syslog

func NewSysLogger

func NewSysLogger(name string, logEventEmitter LogEventEmitter) *SysLogger

NewSysLogger create a local syslog

func (*SysLogger) Close

func (sl *SysLogger) Close() error

Close close the logger

func (*SysLogger) Write

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

Write write the log to syslog

Jump to

Keyboard shortcuts

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