Documentation ¶
Overview ¶
Package gologger defines an interface and logger based on logrus(https://github.com/sirupsen/logrus) library, implementing out-of-the-box features such as: - singleton logic - debuging option (`WithDebugLevel(true)`) - decorated output (`WithRunTimeContext()`) - nologger option (`WithNullLogger()`) - option to write loggin output to file - convenience methods to create new logger instances (i.e. `(l) func NewLoggerWithField()`) - option to set custom log level
package log implements a custom logger based on logrus
Index ¶
- type ILogger
- type Level
- type Logger
- func (l *Logger) GetLevel() Level
- func (l *Logger) IsDebug() bool
- func (l *Logger) NewLoggerWithField(key string, value interface{}) *Logger
- func (l *Logger) NewLoggerWithFields(fields map[string]interface{}) *Logger
- func (l *Logger) SetLevel(level Level)
- func (l *Logger) With(key string, value interface{}) ILogger
- func (l *Logger) WithField(key string, value interface{}) *Logger
- type Option
- func WithDebugLevel(debug bool) Option
- func WithField(msg string, val interface{}) Option
- func WithFields(fields map[string]interface{}) Option
- func WithFiles(outputFile string, errorFile string) Option
- func WithLevel(level Level) Option
- func WithNullLogger() Option
- func WithOutput(output io.Writer) Option
- func WithRuntimeContext() Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Level ¶ added in v0.0.2
type Level uint32
const ( // PanicLevel level, highest level of severity. Logs and then calls panic with the // message passed to Debug, Info, ... PanicLevel Level = iota // FatalLevel level. Logs and then calls `logger.Exit(1)`. It will exit even if the // logging level is set to Panic. FatalLevel // ErrorLevel level. Logs. Used for errors that should definitely be noted. // Commonly used for hooks to send errors to an error tracking service. ErrorLevel // WarnLevel level. Non-critical entries that deserve eyes. WarnLevel // InfoLevel level. General operational entries about what's going on inside the // application. InfoLevel // DebugLevel level. Usually only enabled when debugging. Very verbose logging. DebugLevel // TraceLevel level. Designates finer-grained informational events than the Debug. TraceLevel )
type Logger ¶
func (*Logger) NewLoggerWithField ¶
Returns a new logger instance with the given field
func (*Logger) NewLoggerWithFields ¶
Returns a new logger instantiated from the existing logger with the given fields
type Option ¶
func WithDebugLevel ¶
WithDebugLevel sets the log level to debug with some preformatted output (this option is kept for legacy reasons. Use WithLevel instead)
func WithFields ¶
WithFields sets the fields for the logger
func WithLevel ¶ added in v0.0.2
WithLevel sets the log level and the corresponding format for the logger
func WithNullLogger ¶
func WithNullLogger() Option
WithNullLogger sets the logger to discard all output
func WithOutput ¶
WithOutput sets the output for the logger
func WithRuntimeContext ¶
func WithRuntimeContext() Option
WithRuntimeContext sets the logger to include runtime context