Skip to content

Commit b3d8cc5

Browse files
committed
Update README.md
1 parent 4e65b88 commit b3d8cc5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ we can use this feature to add differentiated fields to different modules.
108108
SubLog1 := BaseLog.WithField("key", value)
109109
SubLog2 := BaseLog.WithFields(map[string]interface{}{/* multiple fields */})
110110
SubLog3 := BaseLog.WithContext(ctx)
111+
// Field key-value pairs are also supported.
112+
SubLog4 := BaseLog.WithFieldPairs("key1", value1, "key2", value2, /* More ... */)
111113
/* More ... */
112114

113115
// Add a logger for the submodule, the logs recorded by the submodule all have
@@ -134,6 +136,14 @@ The application is not a modular design? No additional properties?
134136
log.Info("Step 2 is done!") // Log message: "Prefix: Step 2 is done!"
135137
```
136138

139+
Need to determine if a log level is visible before logging?
140+
141+
```go
142+
if Log.IsLevelEnabled(Level) { /* Print log */ }
143+
// or
144+
if Log.IsDebugLevelEnabled() { /* Print debug log */ }
145+
```
146+
137147
### Quickly Locate Bugs ###
138148

139149
The purpose of the log is to observe the running status of our application.

0 commit comments

Comments
 (0)