Documentation
¶
Index ¶
- type FastLogger
- func (l *FastLogger) BytesWritten(bw int) Logger
- func (l *FastLogger) Debug(msg string)
- func (l *FastLogger) Duration(d time.Duration) Logger
- func (l *FastLogger) Error(msg string, err error)
- func (l *FastLogger) Event(e string) Logger
- func (l *FastLogger) Fatal(msg string, err error)
- func (l *FastLogger) Host(h string) Logger
- func (l *FastLogger) Info(msg string)
- func (l *FastLogger) Method(m string) Logger
- func (l *FastLogger) Panic(msg string)
- func (l *FastLogger) RemoteAddr(addr string) Logger
- func (l *FastLogger) RequestID(id string) Logger
- func (l *FastLogger) Signal(sig fmt.Stringer) Logger
- func (l *FastLogger) StatusCode(sc int) Logger
- func (l *FastLogger) URI(uri string) Logger
- func (l *FastLogger) UserAgent(ua string) Logger
- func (l *FastLogger) Warn(msg string)
- type LogKey
- type LogLevel
- type Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FastLogger ¶
type FastLogger struct {
// contains filtered or unexported fields
}
FastLogger implements the LogChainer interface and relies on http://github.com/rs/zerolog.
func GetConsoleLogger ¶
func GetConsoleLogger(service string, logLevel LogLevel) *FastLogger
GetConsoleLogger returns a pointer to a Logger that logs from logLevel and above to standard output in colorised human readable format. The logger is instructed to include in each log message the name of the service received in input.
func GetLogger ¶
func GetLogger(service string, logLevel LogLevel) *FastLogger
GetLogger returns a pointer to a Logger that logs from logLevel and above. The logger is instructed to include in each log message the name of the service received in input.
func GetLoggerString ¶
func GetLoggerString(service string, logLevel string) *FastLogger
GetLoggerString - alternative Logger constructor that returns a pointer to a Logger based on a string defining a log level. The default value is INFO.
func (*FastLogger) BytesWritten ¶ added in v0.2.0
func (l *FastLogger) BytesWritten(bw int) Logger
BytesWritten instructs the logger to log the bytes written.
func (*FastLogger) Debug ¶
func (l *FastLogger) Debug(msg string)
Debug logs the message at debug level. The log payload will contain everything else the logger has been instructed to log.
func (*FastLogger) Duration ¶ added in v0.2.0
func (l *FastLogger) Duration(d time.Duration) Logger
Duration instructs the logger to log the duration.
func (*FastLogger) Error ¶
func (l *FastLogger) Error(msg string, err error)
Error logs the message and the error at error level. The log payload will contain everything else the logger has been instructed to log.
func (*FastLogger) Event ¶
func (l *FastLogger) Event(e string) Logger
Event instructs the logger to log the event.
func (*FastLogger) Fatal ¶
func (l *FastLogger) Fatal(msg string, err error)
Fatal logs the message and the error at fatal level. It after exits with os.Exit(1). The log payload will contain everything else the logger has been instructed to log.
func (*FastLogger) Host ¶ added in v0.2.0
func (l *FastLogger) Host(h string) Logger
Host instructs the logger to log the host.
func (*FastLogger) Info ¶
func (l *FastLogger) Info(msg string)
Info logs the message at info level. The log payload will contain everything else the logger has been instructed to log.
func (*FastLogger) Method ¶ added in v0.2.0
func (l *FastLogger) Method(m string) Logger
Method instructs the logger to log the method.
func (*FastLogger) Panic ¶
func (l *FastLogger) Panic(msg string)
Panic logs the message at panic level. It stops the ordinary flow of a goroutine. The log payload will contain everything else the logger has been instructed to log.
func (*FastLogger) RemoteAddr ¶ added in v0.2.0
func (l *FastLogger) RemoteAddr(addr string) Logger
RemoteAddr instructs the logger to log the remote address.
func (*FastLogger) RequestID ¶
func (l *FastLogger) RequestID(id string) Logger
RequestID instructs the logger to log the request ID.
func (*FastLogger) Signal ¶
func (l *FastLogger) Signal(sig fmt.Stringer) Logger
Signal instructs the logger to log the signal.
func (*FastLogger) StatusCode ¶
func (l *FastLogger) StatusCode(sc int) Logger
StatusCode instructs the logger to log the status code.
func (*FastLogger) URI ¶ added in v0.2.0
func (l *FastLogger) URI(uri string) Logger
URI instructs the logger to log the URI.
func (*FastLogger) UserAgent ¶ added in v0.2.0
func (l *FastLogger) UserAgent(ua string) Logger
UserAgent instructs the logger to log the user agent.
func (*FastLogger) Warn ¶
func (l *FastLogger) Warn(msg string)
Warn logs the message at warning level. The log payload will contain everything else the logger has been instructed to log.
type LogLevel ¶
type LogLevel int
LogLevel represents the logging level.
func ParseLogLevel ¶
ParseLogLevel parses the input string and returns the respective log level.
type Logger ¶
type Logger interface { BytesWritten(int) Logger Duration(time.Duration) Logger Host(string) Logger Method(string) Logger Event(string) Logger RequestID(string) Logger RemoteAddr(string) Logger StatusCode(int) Logger Signal(fmt.Stringer) Logger URI(string) Logger UserAgent(string) Logger // These are the last functions that should be called on a log chain. // These will execute and log all the information Panic(msg string) Fatal(msg string, err error) Error(msg string, err error) Warn(msg string) Info(msg string) Debug(msg string) }
Logger defines the behavior of the logger. Exposes a function for each loggable field which maps to a LogKey. The functions invocations can be chained and terminated by one of the levelled function calls (Fatal, Error, Warn, Info).