Documentation ¶
Index ¶
- type ConsoleLogger
- type ConsoleTransport
- type FileLogger
- type FileTransport
- type ITransport
- type Level
- type LogData
- type Logger
- type LoggerCore
- func (l *LoggerCore) AddTransport(name string, transport ITransport)
- func (l *LoggerCore) Close()
- func (l *LoggerCore) CloseAllTransport()
- func (l *LoggerCore) CloseTransport(name string)
- func (l *LoggerCore) Debug(format string, v ...interface{})
- func (l *LoggerCore) DisableTransport(name string)
- func (l *LoggerCore) EnableTransport(name string)
- func (l *LoggerCore) Error(format string, v ...interface{})
- func (l *LoggerCore) Fatal(format string, v ...interface{})
- func (l *LoggerCore) Flush()
- func (l *LoggerCore) FlushSync()
- func (l *LoggerCore) GetTransport(name string) ITransport
- func (l *LoggerCore) Info(format string, v ...interface{})
- func (l *LoggerCore) Log(level Level, tags map[string]string, format string, v ...interface{})
- func (l *LoggerCore) ReloadAllTransports()
- func (l *LoggerCore) ReloadTransport(name string)
- func (l *LoggerCore) RemoveTransport(name string)
- func (l *LoggerCore) Trace(format string, v ...interface{})
- func (l *LoggerCore) Warn(format string, v ...interface{})
- type LoggerOptions
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConsoleLogger ¶
type ConsoleLogger struct {
*LoggerCore
}
ConsoleLogger is a struct that contains a pointer to LoggerCore
func NewConsoleLogger ¶
func NewConsoleLogger(name string, level Level) *ConsoleLogger
NewConsoleLogger creates a new ConsoleLogger with the given name and level
type ConsoleTransport ¶
type ConsoleTransport struct {
*Transport
}
ConsoleTransport is a struct that represents a console transport
func NewConsoleTransport ¶
func NewConsoleTransport(name string, level Level) *ConsoleTransport
NewConsoleTransport creates a new ConsoleTransport instance
func (*ConsoleTransport) Log ¶
func (c *ConsoleTransport) Log(data *LogData)
Log logs the formatted data to the console
type FileLogger ¶
type FileLogger struct {
*LoggerCore
}
FileLogger is a struct that contains a pointer to LoggerCore
func NewFileLogger ¶
func NewFileLogger(name string, level Level, filepath string) *FileLogger
NewFileLogger creates a new FileLogger with the given name, level, and filepath
type FileTransport ¶
type FileTransport struct { *Transport // contains filtered or unexported fields }
FileTransport is a struct that represents transport for logging to a file.
func NewFileTransport ¶
func NewFileTransport(name string, level Level, filepath string) *FileTransport
NewFileTransport is a constructor function that creates a new instance of FileTransport.
func (*FileTransport) Close ¶
func (f *FileTransport) Close()
Close is a method that flushes the writer's buffer to the file and closes the file.
func (*FileTransport) Flush ¶
func (f *FileTransport) Flush()
Flush is a method that flushes the writer's buffer to the file.
func (*FileTransport) FlushSync ¶
func (f *FileTransport) FlushSync()
FlushSync is a method that synchronously flushes the writer's buffer to the file.
func (*FileTransport) Log ¶
func (f *FileTransport) Log(data *LogData)
Log is a method that writes formattedData to the file.
func (*FileTransport) Reload ¶
func (f *FileTransport) Reload()
Reload is a method that flushes the writer's buffer to the file, reloads the file, and closes the old file.
type ITransport ¶
type ITransport interface { Enable() Disable() ShouldLog(level Level) bool Log(data *LogData) Flush() FlushSync() Reload() Close() }
ITransport Define an interface called ITransport with several methods
type Logger ¶
type Logger struct {
*LoggerCore
}
Logger is a struct that contains a pointer to LoggerCore
func NewLogger ¶
func NewLogger(options *LoggerOptions) *Logger
NewLogger creates a new Logger with the given options
type LoggerCore ¶
type LoggerCore struct {
// contains filtered or unexported fields
}
func NewLoggerCore ¶
func NewLoggerCore(name string, level Level) *LoggerCore
NewLoggerCore creates a new LoggerCore instance
func (*LoggerCore) AddTransport ¶
func (l *LoggerCore) AddTransport(name string, transport ITransport)
AddTransport adds new transport to the logger
func (*LoggerCore) CloseAllTransport ¶
func (l *LoggerCore) CloseAllTransport()
CloseAllTransport closes all transports
func (*LoggerCore) CloseTransport ¶
func (l *LoggerCore) CloseTransport(name string)
CloseTransport closes the transport with the given name
func (*LoggerCore) Debug ¶
func (l *LoggerCore) Debug(format string, v ...interface{})
Debug logs a message with the DEBUG level
func (*LoggerCore) DisableTransport ¶
func (l *LoggerCore) DisableTransport(name string)
DisableTransport disables the transport with the given name
func (*LoggerCore) EnableTransport ¶
func (l *LoggerCore) EnableTransport(name string)
EnableTransport enables the transport with the given name
func (*LoggerCore) Error ¶
func (l *LoggerCore) Error(format string, v ...interface{})
Error logs a message with the ERROR level
func (*LoggerCore) Fatal ¶
func (l *LoggerCore) Fatal(format string, v ...interface{})
Fatal logs a message with the FATAL level
func (*LoggerCore) FlushSync ¶
func (l *LoggerCore) FlushSync()
FlushSync flushes all transports synchronously
func (*LoggerCore) GetTransport ¶
func (l *LoggerCore) GetTransport(name string) ITransport
GetTransport returns the transport with the given name
func (*LoggerCore) Info ¶
func (l *LoggerCore) Info(format string, v ...interface{})
Info logs a message with the INFO level
func (*LoggerCore) Log ¶
func (l *LoggerCore) Log(level Level, tags map[string]string, format string, v ...interface{})
Log logs a message with the given level and format
func (*LoggerCore) ReloadAllTransports ¶
func (l *LoggerCore) ReloadAllTransports()
ReloadAllTransports reloads all transports
func (*LoggerCore) ReloadTransport ¶
func (l *LoggerCore) ReloadTransport(name string)
ReloadTransport reloads the transport with the given name
func (*LoggerCore) RemoveTransport ¶
func (l *LoggerCore) RemoveTransport(name string)
RemoveTransport removes the transport with the given name
func (*LoggerCore) Trace ¶
func (l *LoggerCore) Trace(format string, v ...interface{})
Trace logs a message with the TRACE level
func (*LoggerCore) Warn ¶
func (l *LoggerCore) Warn(format string, v ...interface{})
Warn logs a message with the WARN level
type LoggerOptions ¶
type LoggerOptions struct { Name string // Name of the logger Level Level // Level of the logger Filepath string // Filepath for the logger }
LoggerOptions is a struct that contains options for creating a new Logger