In this version the following features were added:
- New
LoggerBuilderdefinition that defines the contract for a logger constructor function. ThisLoggerBuildertype is an alias forfunc(name string, writer ...io.Writer) ILogger, wherenamespecifies the name of the logger,writeris an optional (variadic) variable that is passed, it it should be used to write the logger output when creating a new logger with this builder.\ - New static function
log.New(name string, writer ...io.Writer)which uses a default logger builder. - New static function
log.SetDefaultBuilder(ctor LoggerBuilder)which allows to specify a default constructor function to use bylog.Get(name string)andlog.New(name string, writer ...io.Writer)when creating new loggers. By default, the default logger builder is set to a Loggrus builderlog.NewLogrus(name string, writer ...io.Writer)
-log.Get(name string)will now create a logger using the default builder if a logger by the given name does not exist. - Added the logger name in the templates for the predefined formatters. By default the logger name will only be shown in the logs if it has been assigned. The default logger is meant for global use which does not have a name defined.