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
+7-6
Original file line number
Diff line number
Diff line change
@@ -59,13 +59,14 @@ func init() {
59
59
60
60
- The `0` is an integer type so it is used as underlying buffer size. In this case, `0` creates synchronized logger (call hangs until write is finished).
61
61
- Any non-integer type is used as the config object, in this case `ConsoleConfig` is the respective config object for the console logger.
62
-
- The `LevelTrace` used here is the lowest logging level, meaning prints every log to the console. All levels from lowest to highest are: `LevelTrace`, `LevelInfo`, `LevelWarn`, `LevelError`, `LevelFatal`, each of has at least one repective function, e.g. `log.Trace`, `log.Info`, `log.Warn`, `log.Error` and `log.Fatal`.
62
+
- The `LevelTrace` used here is the lowest logging level, meaning prints every log to the console. All levels from lowest to highest are: `LevelTrace`, `LevelInfo`, `LevelWarn`, `LevelError`, `LevelFatal`, each of them has at least one respective function, e.g. `log.Trace`, `log.Info`, `log.Warn`, `log.Error` and `log.Fatal`.
63
63
64
64
In production, you may want to make log less verbose and be asynchronous:
65
65
66
66
```go
67
67
funcinit() {
68
-
// The buffer size mainly depends on how many logs will be produced at the same time, 100 is a good default.
68
+
// The buffer size mainly depends on number of logs could be produced at the same time,
- When you set level to be `LevelInfo`, calls to the `log.Trace` will be simply noop.
79
80
- The console logger comes with color output, but for non-colorable destination, the color output will be disabled automatically.
80
81
81
-
Other builtin loggers are file (`log.ModeFile`), Slack (`log.ModeSlack`) and Discord (`log.Discord`), see later in the documentation for usage details.
82
+
Other builtin loggers are file (`log.ModeFile`), Slack (`log.ModeSlack`) and Discord (`log.ModeDiscord`), see later sections in the documentation for usage details.
82
83
83
84
### Multiple Loggers
84
85
85
-
You can have multiple loggers in different modes with levels.
86
+
You can have multiple loggers in different modes across levels.
86
87
87
88
```go
88
89
funcinit() {
@@ -91,8 +92,8 @@ func init() {
91
92
panic("unable to create new logger: " + err.Error())
92
93
}
93
94
err:= log.New(log.ModeFile, log.FileConfig{
94
-
Level: log.LevelInfo,
95
-
Filename: "clog.log",
95
+
Level: log.LevelInfo,
96
+
Filename: "clog.log",
96
97
})
97
98
if err != nil {
98
99
panic("unable to create new logger: " + err.Error())
0 commit comments