mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-21 21:33:22 +01:00
Allow to disable log color output (#288)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -21,6 +21,7 @@ Flags:
|
|||||||
--log-level="info" Set log level ($LOG_LEVEL).
|
--log-level="info" Set log level ($LOG_LEVEL).
|
||||||
--log-json Enable JSON logging output ($LOG_JSON).
|
--log-json Enable JSON logging output ($LOG_JSON).
|
||||||
--log-caller Add file:line of the caller to log output ($LOG_CALLER).
|
--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.
|
--test-notif Test notification settings.
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -34,3 +35,4 @@ Following environment variables can be used in place:
|
|||||||
| `LOG_LEVEL` | `info` | Log level output |
|
| `LOG_LEVEL` | `info` | Log level output |
|
||||||
| `LOG_JSON` | `false` | Enable JSON logging output |
|
| `LOG_JSON` | `false` | Enable JSON logging output |
|
||||||
| `LOG_CALLER` | `false` | Enable to add `file:line` of the caller |
|
| `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 {
|
if !cli.LogJSON {
|
||||||
w = zerolog.ConsoleWriter{
|
w = zerolog.ConsoleWriter{
|
||||||
Out: os.Stdout,
|
Out: os.Stdout,
|
||||||
|
NoColor: cli.LogNoColor,
|
||||||
TimeFormat: time.RFC1123,
|
TimeFormat: time.RFC1123,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ import "github.com/alecthomas/kong"
|
|||||||
|
|
||||||
// Cli holds command line args, flags and cmds
|
// Cli holds command line args, flags and cmds
|
||||||
type Cli struct {
|
type Cli struct {
|
||||||
Version kong.VersionFlag
|
Version kong.VersionFlag
|
||||||
Cfgfile string `kong:"name='config',env='CONFIG',help='Diun configuration file.'"`
|
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.'"`
|
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.'"`
|
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.'"`
|
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.'"`
|
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.'"`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user