Documentation
¶
Overview ¶
Package logger provides methods for logging with different levels.
Index ¶
- Constants
- func Debugf(ctx context.Context, format string, a ...interface{})
- func Errorf(ctx context.Context, format string, a ...interface{})
- func Fatalf(ctx context.Context, format string, a ...interface{})
- func Infof(ctx context.Context, format string, a ...interface{})
- func Logf(ctx context.Context, logLevel LogLevel, format string, a ...interface{})
- func Tracef(ctx context.Context, format string, a ...interface{})
- func Warningf(ctx context.Context, format string, a ...interface{})
- func WithLogger(ctx context.Context, logger *Logger) context.Context
- type LogLevel
- type Logger
- func (l *Logger) Debugf(format string, a ...interface{})
- func (l *Logger) Errorf(format string, a ...interface{})
- func (l *Logger) Fatalf(format string, a ...interface{})
- func (l *Logger) Infof(format string, a ...interface{})
- func (l *Logger) SetFlags(flags int)
- func (l *Logger) Tracef(format string, a ...interface{})
- func (l *Logger) Warningf(format string, a ...interface{})
Constants ¶
const ( Ldate = 1 << iota // the date in the local time zone: 2009/01/23 Ltime // the time in the local time zone: 01:23:23 Lmicroseconds // microsecond resolution: 01:23:23.123123. assumes Ltime. Llongfile // full file name and line number: /a/b/c/d.go:23 Lshortfile // final file name element and line number: d.go:23. overrides Llongfile LUTC // if Ldate or Ltime is set, use UTC rather than the local time zone Lmsgprefix // move the "prefix" from the beginning of the line to before the message LstdFlags = Ldate | Lmicroseconds // initial values for the standard logger )
Copied from Go log so callers don't need to also import log.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LogLevel ¶
type LogLevel int
LogLevel represents different levels for logging depending on the amount of detail wanted.
type Logger ¶
type Logger struct { LoggerLevel LogLevel // contains filtered or unexported fields }
Logger represents a specific LogLevel with a specified color and prefix.
func LoggerFromContext ¶
LoggerFromContext returns the context logger if configured, otherwise nil.
func NewLogger ¶
func NewLogger(loggerLevel LogLevel, color color.Color, outWriter, errWriter io.Writer, prefix interface{}) *Logger
NewLogger creates a new logger instance. The loggerLevel variable sets the log level for the logger. The color variable specifies the visual color of displayed log output. The outWriter and errWriter variables set the destination to which non-error and error data will be written. The prefix appears on the same line directly preceding any log data. It should be thread-safe to format this value.