Repository navigation
Commit 50cabe7
authored
Make the log level of Go services configurable (#2413)
Summary: Make the log level of Go services configurable
Every Go service in Pixie Cloud and Vizier calls
`services.SetupServiceLogging()`, which hard coded the logrus level to
`info`. As discussed in the issue, there was no way to reduce log volume
or turn on debug logging without rebuilding.
Following the approach suggested in the issue, this PR adds a common
`--log_level` flag to `service_flags.go` and uses it in
`SetupServiceLogging()`. Like the other service flags, it can also be
set with the `PL_LOG_LEVEL` environment variable. It accepts any logrus
level (`panic`, `fatal`, `error`, `warn`, `info`, `debug`, `trace`, case
insensitive) and defaults to `info`, so current deployments behave
exactly as before. An invalid value is a fatal configuration error, the
same way `CheckServiceFlags()` handles other invalid flags.
The level is applied after flags are parsed, so the `Starting service`
line that `SetupService()` logs before parsing is still printed at info
level.
This only affects the Go logrus logger. The C++ (glog) logging in PEM,
Kelvin and the query broker already has its own runtime flags.
Relevant Issues: Fixes #2280
Type of change: /kind feature
Test Plan: Added `//src/shared/services:services_test`, which checks the
default level, explicit levels, case insensitivity, and that an invalid
level is fatal. The explicit level cases fail on `main`. I also built
`scriptmgr` and ran it locally. With no flag it logs at info. With
`--log_level=error`, only error logs are printed after startup. With
`PL_LOG_LEVEL=debug`, debug logs are printed. With `--log_level=bogus`,
it exits with `Flag --log_level or ENV PL_LOG_LEVEL is invalid`. `go
vet` and golangci-lint v2.3.1 with the repo's `.golangci.yaml` are
clean.
Changelog Message:
```release-note
Go services in Pixie Cloud and Vizier now accept a `--log_level` flag (or `PL_LOG_LEVEL` environment variable) to configure their log level. The default remains `info`.
```
Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>1 parent 3e3350f commit 50cabe7
4 files changed
Lines changed: 118 additions & 1 deletion
File tree
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
0 commit comments