Skip to content

Commit

Permalink
Add std logger intercept (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldemailly authored Aug 4, 2023
1 parent 56493ac commit 4979aab
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Extends [cli](https://github.com/fortio/cli#cli) to server `main()`s .

In addition to flags, usage and help output, arguments validation, `scli` abstracts the repetitive parts of a `main()` to setup a config directory watch for [dynamic flags](https://github.com/fortio/dflag) (configmap in kubernetes cases) and configuration endpoint/UI/api.

It also sets up standard library logger interception to log these under same JSON (or color console) format.

You can see real use example in a server like [proxy](https://github.com/fortio/proxy).

## Server Example
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
fortio.org/cli v1.3.3
fortio.org/dflag v1.5.3
fortio.org/log v1.9.3
fortio.org/log v1.10.0
fortio.org/version v1.0.2
golang.org/x/sys v0.10.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ fortio.org/cli v1.3.3 h1:b2JPQ7ekVFpF7SrEllJTbh1rdivsyXT081oQUeiuIp0=
fortio.org/cli v1.3.3/go.mod h1:ZsevXTvMidh3xllYoAElS52XRcGx+f1hVlgB+v2Pa0Y=
fortio.org/dflag v1.5.3 h1:+pCqZBCz95PYTxhcmenjrkVORWIRB1Je4eO/So574Bc=
fortio.org/dflag v1.5.3/go.mod h1:cM/ojIzdDv8FRA5yqSRpDK9jCGmASln0k7ag3zeiqbw=
fortio.org/log v1.9.3 h1:rkgDmgF7dLfNRtVOE44Av5KBlro8FkpTKnTnphHy074=
fortio.org/log v1.9.3/go.mod h1:u/8/2lyczXq52aT5Nw6reD+3cR6m/EbS2jBiIYhgiTU=
fortio.org/log v1.10.0 h1:Id2z9HjGlof0VsIHi2XNI9k+tG7ujODVDnAAvkSgpuE=
fortio.org/log v1.10.0/go.mod h1:u/8/2lyczXq52aT5Nw6reD+3cR6m/EbS2jBiIYhgiTU=
fortio.org/sets v1.0.3 h1:HzewdGjH69YmyW06yzplL35lGr+X4OcqQt0qS6jbaO4=
fortio.org/sets v1.0.3/go.mod h1:QZVj0r6KP/ZD9ebySW9SgxVNy/NjghUfyHW9NN+WU+4=
fortio.org/version v1.0.2 h1:8NwxdX58aoeKx7T5xAPO0xlUu1Hpk42nRz5s6e6eKZ0=
Expand Down
4 changes: 4 additions & 0 deletions scli.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ func ServerMain() bool {
log.Critf("Unable to watch config/flag changes in %v: %v", *configDir, err)
}
}

// So http client library for instance ends up logging in JSON or color too and not break json parsing.
log.InterceptStandardLogger(log.Warning)

shortScliV, _, _ := version.FromBuildInfoPath("fortio.org/scli")

hasStartedServer := false
Expand Down

0 comments on commit 4979aab

Please sign in to comment.