You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -81,19 +81,19 @@ type ILogger interface {
81
81
## The factory
82
82
Simply provides the following functions
83
83
84
+
*`New(name string, writer ...io.Writer) ILogger`: Creates a new logger instance using the default builder assigned.
85
+
*`name`: The name of the logger to create.
86
+
*`writer`: (Optional) The io.Writer the logger instance should use. If not provided, it is set to the default writer by the implementation, typically Stdout or Stderr
84
87
*`Register(name string, logger ILogger)`: Registers an instance of ILogger to be returned as the singleton instance by the given name.
85
-
*`name`: The logger implementation name.
88
+
*`name`: The logger name.
86
89
*`logger`: The logger instance.
87
-
*`RegisterBuilder(name string, ctor func(...interface{}) ILogger)`: Registers an ILogger constructor function which will be used to create a new instance of the logger when requested instance by the given name. The constructor allows a variadic interface{} array that can be used for optional constructor variables, such as the instance name of a logger, the package name where it is used, etc. It is up to the custom implementation of a logger to use these values.
88
-
*`name`: The logger implementation name.
89
-
*`ctor`: The constructor function used to create the ILogger instance.
90
-
*`Get(name string, args ...interface{}) ILogger`: Returns an instance of the requested logger by its name. Returns nil if a logger by that name has not been previously registered.
91
-
*`name`: The implementation name of the instance to be retrieved.
92
-
*`args`: Variadic interface{} array as optional arguments for a registered logger constructor.
93
-
*`List() []string`: Returns the list of loggers that have been registered to the factory.
94
-
*`Contains(name string) bool`: Contains indicates if a logger by the given name is contained by the factory.
95
-
96
-
## Predefined loggers
90
+
*`Get(name string) ILogger`: Returns an instance of the requested logger by its name. Creates a new logger with the default logger builder if the logger does not exist.
91
+
*`name`: The name of the logger instance to be retrieved.
92
+
*`List() []string`: Returns the list of loggers that have been registered.
93
+
*`Contains(name string) bool`: Indicates if a logger by the given name exists.
94
+
*`SetDefaultBuilder(ctor LoggerBuilder)` Assigns a new constructor function to use as the default logger constructor.
95
+
96
+
## Predefined logger types
97
97
98
98
***Logrus**: Predefined logger implementation powered by `github.com/sirupsen/logrus`. It is assigned as default to be de default logger which responds to the static functions in the `log` package. Can also be obtained by the using the `"logrus"` name (also defined in the `LoggerLogrus` constant). Eg: `log.Get(log.LoggerLogrus)`
99
99
***Nil Logger**: This implementation, as the name suggests, is a logger that does nothing when its functions are called. Can be obtained by the using the `"nil"` name (also defined in the `LoggerNil` constant). Eg: `log.Get(log.LoggerNil)`. To easily set the Nil Logger as the default logger, simply pass `nil` value to the `log.SetDefault` function. Eg `log.SetDefault(nil)`
0 commit comments