Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
edoger committed May 6, 2023
1 parent 4e65b88 commit b3d8cc5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ we can use this feature to add differentiated fields to different modules.
SubLog1 := BaseLog.WithField("key", value)
SubLog2 := BaseLog.WithFields(map[string]interface{}{/* multiple fields */})
SubLog3 := BaseLog.WithContext(ctx)
// Field key-value pairs are also supported.
SubLog4 := BaseLog.WithFieldPairs("key1", value1, "key2", value2, /* More ... */)
/* More ... */

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

Need to determine if a log level is visible before logging?

```go
if Log.IsLevelEnabled(Level) { /* Print log */ }
// or
if Log.IsDebugLevelEnabled() { /* Print debug log */ }
```

### Quickly Locate Bugs ###

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

0 comments on commit b3d8cc5

Please sign in to comment.