Skip to content

Commit e4be91a

Browse files
author
Lars Ekman
committed
Doc updates
1 parent 9c11bbe commit e4be91a

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

docs/logging.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,25 @@ use the logger from the context;
6767
// In main();
6868
ctx = logr.NewContext(ctx, logger)
6969
// In a function;
70-
logger = log.FromContextOrDefault(ctx)
70+
logger = log.FromContextOrGlobal(ctx)
7171
```
7272

7373
Functions really should always have a context as first parameter but
74-
during transition they might not. A global logger is provided;
74+
they might not. A global logger is provided;
7575

7676
```
7777
log.Logger.Info("Configuration read", "config", config)
7878
```
7979

8080
The global logger it the one returnad by the *first* call to `log.New`
81-
or a logger named "Meridio" and always on INFO level if `log.New` is
82-
not called.
81+
or a logger named "Meridio" and always on INFO level before `log.New` is
82+
called.
8383

8484

8585

8686
## Log levels
8787

88-
Only severity `info`, `error` and `critical` are used (not `warning`) but
88+
Severity `debug`, `info`, `error` and `critical` are used (not `warning`).
8989
`info` can have different "verbosity" set with the `V(n)` method;
9090

9191
```go
@@ -94,9 +94,9 @@ logger.V(1).Info("This is a debug message")
9494
logger.V(2).Info("This is a trace message")
9595
```
9696

97-
There is no "trace" level so both trace and debug messages will be
98-
shown as "debug". The level setting is still valid though, trace
99-
messages are suspressed unless TRACE level is set.
97+
There is no defined "trace" level so both trace and debug messages
98+
will be shown as "debug". The level filtering is still valid though,
99+
trace messages are suspressed unless TRACE level is set.
100100

101101
The `Fatal()` function logs on `critical` level.
102102

@@ -154,8 +154,8 @@ Example output;
154154
## Design patterns
155155

156156
Patterns must evolve slowly to get really good so these are mere
157-
ideas. It is very easy to get carried away and impose some over
158-
structured logging that floods the logs with useless data.
157+
ideas. It is very easy to get carried away and impose some
158+
over-structured logging that floods the logs with useless data.
159159

160160

161161
### Class logger
@@ -167,7 +167,7 @@ A logger used in a type (Class) can be decorated with `class` and
167167
type someHandler struct {
168168
ctx context.Context
169169
logger logr.Logger
170-
Adr *net.TCPAddr // Capitalized to make it visible!
170+
Adr *net.TCPAddr // (optional; capitalized to make it visible)
171171
}
172172

173173
func newHandler(ctx context.Context, addr string) *someHandler {
@@ -181,7 +181,7 @@ func newHandler(ctx context.Context, addr string) *someHandler {
181181
logger: logger.WithValues("instance", adr),
182182
Adr: adr,
183183
}
184-
h.logger.Info("Created")
184+
h.logger.Info("Created", "object", h)
185185
return h
186186
}
187187

@@ -193,8 +193,8 @@ func (h *someHandler) connect() error {
193193
```
194194

195195
The `class` is the name of the type and `instance` can be anything
196-
that identifies an instance. Remember that the instance field must be
197-
visible (Capitalized).
196+
that identifies an instance. The instance field must be
197+
capitalized if you want it visible.
198198

199199
The example shows a `func` entry to identify a function. This should
200200
*not* be used as a common pattern but may be handy in some cases.

0 commit comments

Comments
 (0)