Documentation
¶
Index ¶
- Constants
- Variables
- func GetLastLines(n int) []string
- func InitLoggerOutputs()
- func InitProduction()
- func LogPanic(rec interface{})
- func RecoverAndLog(f func())
- func SetGlobalLogger(logger interface{})
- type LogBuffer
- type Logger
- func (l *Logger) Debug(msg string)
- func (l *Logger) DebugWithFields(msg string, fields ...zap.Field)
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Error(msg string)
- func (l *Logger) ErrorWithFields(msg string, fields ...zap.Field)
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Fatal(msg string)
- func (l *Logger) Fatalf(format string, args ...interface{})
- func (l *Logger) Info(msg string)
- func (l *Logger) InfoWithFields(msg string, fields ...zap.Field)
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) PrintLogs(t *testing.T)
- func (l *Logger) SetVerbose(verbose bool)
- func (l *Logger) Warn(msg string)
- func (l *Logger) WarnWithFields(msg string, fields ...zap.Field)
- func (l *Logger) Warnf(format string, args ...interface{})
- func (l *Logger) With(fields ...zap.Field) Loggerer
- type Loggerer
- type TestLogger
- func (tl *TestLogger) Debug(msg string)
- func (tl *TestLogger) Error(msg string)
- func (tl *TestLogger) GetLastLines(n int) []string
- func (tl *TestLogger) GetLogs() []string
- func (tl *TestLogger) Info(msg string)
- func (tl *TestLogger) PrintLogs(t *testing.T)
- func (tl *TestLogger) Warn(msg string)
- func (tl *TestLogger) With(fields ...zap.Field) Loggerer
Constants ¶
View Source
const ( LogFilePermissions = 0600 DebugFilePermissions = 0600 ProfileFilePermissions = 0600 InfoLogLevel = "info" )
Constants
Variables ¶
View Source
var ( // Log levels DEBUG zapcore.Level = zapcore.DebugLevel INFO zapcore.Level = zapcore.InfoLevel WARN zapcore.Level = zapcore.WarnLevel ERROR zapcore.Level = zapcore.ErrorLevel // Global settings GlobalEnableConsoleLogger bool GlobalEnableFileLogger bool GlobalEnableBufferLogger bool GlobalLogPath string = "/tmp/andaime.log" GlobalLogLevel string = InfoLogLevel GlobalInstantSync bool GlobalLoggedBuffer strings.Builder GlobalLoggedBufferSize int = 8192 GlobalLogFile *os.File )
Global variables
Functions ¶
func GetLastLines ¶
GetLastLines gets the last n lines from the log
func InitProduction ¶
func InitProduction()
func RecoverAndLog ¶
func RecoverAndLog(f func())
func SetGlobalLogger ¶
func SetGlobalLogger(logger interface{})
Types ¶
type LogBuffer ¶ added in v0.0.20
type LogBuffer struct {
// contains filtered or unexported fields
}
LogBuffer maintains a circular buffer of log messages
func NewLogBuffer ¶ added in v0.0.20
NewLogBuffer creates a new log buffer with specified size
func (*LogBuffer) AddLine ¶ added in v0.0.20
AddLine adds a line to the buffer, maintaining the circular buffer behavior
func (*LogBuffer) GetLastLines ¶ added in v0.0.20
GetLastLines returns the last n lines from the buffer
type Logger ¶
Logger types
func NewNopLogger ¶
func NewNopLogger() *Logger
func (*Logger) DebugWithFields ¶ added in v0.0.20
Field logging methods
func (*Logger) ErrorWithFields ¶ added in v0.0.20
func (*Logger) InfoWithFields ¶ added in v0.0.20
func (*Logger) WarnWithFields ¶ added in v0.0.20
type Loggerer ¶ added in v0.0.20
type Loggerer interface { Debug(msg string) Info(msg string) Warn(msg string) Error(msg string) SetVerbose(bool) Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) PrintLogs(*testing.T) With(fields ...zap.Field) Loggerer }
type TestLogger ¶ added in v0.0.20
type TestLogger struct { *Logger // contains filtered or unexported fields }
func (*TestLogger) Debug ¶ added in v0.0.20
func (tl *TestLogger) Debug(msg string)
Test logger methods with capture
func (*TestLogger) Error ¶ added in v0.0.20
func (tl *TestLogger) Error(msg string)
func (*TestLogger) GetLastLines ¶ added in v0.0.20
func (tl *TestLogger) GetLastLines(n int) []string
Update test logger methods to use buffer
func (*TestLogger) GetLogs ¶ added in v0.0.20
func (tl *TestLogger) GetLogs() []string
TestLogger implementation
func (*TestLogger) Info ¶ added in v0.0.20
func (tl *TestLogger) Info(msg string)
func (*TestLogger) PrintLogs ¶ added in v0.0.20
func (tl *TestLogger) PrintLogs(t *testing.T)
PrintLogs prints all captured logs to the test output
func (*TestLogger) Warn ¶ added in v0.0.20
func (tl *TestLogger) Warn(msg string)
Click to show internal directories.
Click to hide internal directories.