mirror of
https://github.com/crazy-max/diun.git
synced 2025-04-17 16:32:35 +00:00
Allow to disable log color output (#288)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
210e0be62e
commit
cad8dfb673
3 changed files with 10 additions and 6 deletions
|
@ -21,6 +21,7 @@ Flags:
|
|||
--log-level="info" Set log level ($LOG_LEVEL).
|
||||
--log-json Enable JSON logging output ($LOG_JSON).
|
||||
--log-caller Add file:line of the caller to log output ($LOG_CALLER).
|
||||
--log-nocolor Disables the colorized output ($LOG_NOCOLOR).
|
||||
--test-notif Test notification settings.
|
||||
```
|
||||
|
||||
|
@ -34,3 +35,4 @@ Following environment variables can be used in place:
|
|||
| `LOG_LEVEL` | `info` | Log level output |
|
||||
| `LOG_JSON` | `false` | Enable JSON logging output |
|
||||
| `LOG_CALLER` | `false` | Enable to add `file:line` of the caller |
|
||||
| `LOG_NOCOLOR` | `false` | Disables the colorized output |
|
||||
|
|
|
@ -20,6 +20,7 @@ func Configure(cli *model.Cli) {
|
|||
if !cli.LogJSON {
|
||||
w = zerolog.ConsoleWriter{
|
||||
Out: os.Stdout,
|
||||
NoColor: cli.LogNoColor,
|
||||
TimeFormat: time.RFC1123,
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -4,10 +4,11 @@ import "github.com/alecthomas/kong"
|
|||
|
||||
// Cli holds command line args, flags and cmds
|
||||
type Cli struct {
|
||||
Version kong.VersionFlag
|
||||
Cfgfile string `kong:"name='config',env='CONFIG',help='Diun configuration file.'"`
|
||||
LogLevel string `kong:"name='log-level',env='LOG_LEVEL',default='info',help='Set log level.'"`
|
||||
LogJSON bool `kong:"name='log-json',env='LOG_JSON',default='false',help='Enable JSON logging output.'"`
|
||||
LogCaller bool `kong:"name='log-caller',env='LOG_CALLER',default='false',help='Add file:line of the caller to log output.'"`
|
||||
TestNotif bool `kong:"name='test-notif',default='false',help='Test notification settings.'"`
|
||||
Version kong.VersionFlag
|
||||
Cfgfile string `kong:"name='config',env='CONFIG',help='Diun configuration file.'"`
|
||||
LogLevel string `kong:"name='log-level',env='LOG_LEVEL',default='info',help='Set log level.'"`
|
||||
LogJSON bool `kong:"name='log-json',env='LOG_JSON',default='false',help='Enable JSON logging output.'"`
|
||||
LogCaller bool `kong:"name='log-caller',env='LOG_CALLER',default='false',help='Add file:line of the caller to log output.'"`
|
||||
LogNoColor bool `kong:"name='log-nocolor',env='LOG_NOCOLOR',default='false',help='Disables the colorized output.'"`
|
||||
TestNotif bool `kong:"name='test-notif',default='false',help='Test notification settings.'"`
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue