0
0
Fork 0
mirror of https://github.com/crazy-max/diun.git synced 2025-04-17 16:32:35 +00:00

Allow to disable log color output ()

Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2021-03-01 00:25:16 +01:00 committed by GitHub
parent 210e0be62e
commit cad8dfb673
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions
docs/usage
internal
logging
model

View file

@ -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 |

View file

@ -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 {

View file

@ -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.'"`
}