Skip to content

Commit b6eaa06

Browse files
author
Brian Lalor
committed
Add readme describing alternate stdlog config scenario
1 parent 61a499a commit b6eaa06

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,21 @@ stdLogger.Printf("[DEBUG] %+v", stdLogger)
128128
... [DEBUG] my-app: &{mu:{state:0 sema:0} prefix: flag:0 out:0xc42000a0a0 buf:[]}
129129
```
130130

131+
Alternatively, you may configure the system-wide logger:
132+
133+
```go
134+
// log the standard logger from 'import "log"'
135+
log.SetOutput(appLogger.Writer(&hclog.StandardLoggerOptions{InferLevels: true}))
136+
log.SetPrefix("")
137+
log.SetFlags(0)
138+
139+
log.Printf("[DEBUG] %d", 42)
140+
```
141+
142+
```text
143+
... [DEBUG] my-app: 42
144+
```
145+
131146
Notice that if `appLogger` is initialized with the `INFO` log level _and_ you
132147
specify `InferLevels: true`, you will not see any output here. You must change
133148
`appLogger` to `DEBUG` to see output. See the docs for more information.

0 commit comments

Comments
 (0)