Documentation
¶
Index ¶
- Constants
- func BuildConsoleWriter(out io.Writer) io.Writer
- func BuildFileWriter(config *WriterConfig) io.Writer
- func Debug() *zerolog.Event
- func Error() *zerolog.Event
- func Fatal() *zerolog.Event
- func GetWriter(config *WriterConfig) io.Writer
- func GroupID(id string) *zerolog.Logger
- func Hook(h zerolog.Hook) zerolog.Logger
- func Info() *zerolog.Event
- func Init()
- func InitWithConfig(config *Config)
- func Log() *zerolog.Event
- func New() *zerolog.Logger
- func NewWithConfig(config *Config) *zerolog.Logger
- func Panic() *zerolog.Event
- func ParseLevel(levelStr string) zerolog.Level
- func ParseVerboseLevel(verbose int) zerolog.Level
- func Print(v ...interface{})
- func Printf(format string, v ...interface{})
- func Trace() *zerolog.Event
- func Warn() *zerolog.Event
- func With() zerolog.Context
- func WithLevel(level zerolog.Level) *zerolog.Event
- type Config
- type LevelWriter
- type Writer
- type WriterConfig
Constants ¶
const ( VerbosityDefault = iota VerbosityInfo VerbosityDebug VerbosityTrace )
const TimeFormat = "2006-01-02 15:04:05.000 -0700"
Variables ¶
This section is empty.
Functions ¶
func BuildConsoleWriter ¶ added in v0.0.4
BuildConsoleWriter returns a new zerolog.ConsoleWriter with the given output writer and a custom time format
func BuildFileWriter ¶ added in v0.0.4
func BuildFileWriter(config *WriterConfig) io.Writer
BuildFileWriter creates a directory if it doesn't exist, then returns a lumberjack.Logger that writes to a file in that directory
func Debug ¶
Debug starts a new message with debug level.
You must call Msg on the returned event in order to send the event.
func Error ¶
Error starts a new message with error level.
You must call Msg on the returned event in order to send the event.
func Fatal ¶
Fatal starts a new message with fatal level. The os.Exit(1) function is called by the Msg method.
You must call Msg on the returned event in order to send the event.
func GetWriter ¶ added in v0.0.4
func GetWriter(config *WriterConfig) io.Writer
GetWriter takes a string and returns an io.Writer
func GroupID ¶
GroupID returns a pointer to a zerolog logger with the `groupId` field set to the value of the `id` parameter
func Info ¶
Info starts a new message with info level.
You must call Msg on the returned event in order to send the event.
func Init ¶
func Init()
Init creates a new logger with the default configuration, and sets it as the default logger
func InitWithConfig ¶ added in v0.0.2
func InitWithConfig(config *Config)
InitWithConfig creates a new logger with the given configuration, and sets it as the default logger
func Log ¶
Log starts a new message with no level. Setting zerolog.GlobalLevel to zerolog.Disabled will still disable events produced by this method.
You must call Msg on the returned event in order to send the event.
func NewWithConfig ¶ added in v0.0.2
NewWithConfig is a function that creates a new logger with the given configuration
func Panic ¶
Panic starts a new message with panic level. The message is also sent to the panic function.
You must call Msg on the returned event in order to send the event.
func ParseLevel ¶
ParseLevel converts a level string into a zerolog Level value. returns an error if the input string does not match known values.
func ParseVerboseLevel ¶ added in v0.0.4
ParseVerboseLevel takes an integer defining the verbosity level and returns a zerolog.Level
func Print ¶
func Print(v ...interface{})
Print sends a log event using debug level and no extra field. Arguments are handled in the manner of fmt.Print.
func Printf ¶
func Printf(format string, v ...interface{})
Printf sends a log event using debug level and no extra field. Arguments are handled in the manner of fmt.Printf.
func Trace ¶ added in v0.0.4
Trace starts a new message with trace level.
You must call Msg on the returned event in order to send the event.
func Warn ¶
Warn starts a new message with warn level.
You must call Msg on the returned event in order to send the event.
Types ¶
type Config ¶
type Config struct {
Debug bool
Verbosity int
WriterConfig *WriterConfig
}
Config is a struct that contains a boolean, a `zerolog.Level` and an `io.Writer`. @property {bool} Debug - This is a boolean value that determines whether the application is running in debug mode or not. @property LogLevel - The level of logging you want to use. @property Writer - The writer to which the logs will be written.
type LevelWriter ¶ added in v0.0.4
func (*LevelWriter) WriteLevel ¶ added in v0.0.4
WriteLevel is a custom writer that allows us to write to a file only if the log level is greater than or equal to the level we set.
type WriterConfig ¶
type WriterConfig struct {
Writer Writer
Directory string
FileName string
MaxSize int
MaxBackups int
MaxAge int
}
WriterConfig is a struct with 6 fields. @property {string} Writer - The writer to use. This can be either "file" or "console". @property {string} Directory - The directory where the log files will be written. @property {string} FileName - The name of the file to write logs to. @property {int} MaxSize - The maximum size in megabytes of the log file before it gets rotated. It defaults to 100 megabytes. @property {int} MaxBackups - The maximum number of old log files to retain. @property {int} MaxAge - The maximum age of a log file in days