mirror of
https://github.com/fleetdm/fleet
synced 2026-05-22 16:39:01 +00:00
support JSON output for kolide logs (#1026)
This commit is contained in:
parent
d45c0103d1
commit
c13b8cc0cf
2 changed files with 14 additions and 7 deletions
18
cli/serve.go
18
cli/serve.go
|
|
@ -47,15 +47,19 @@ binary (which you're executing right now). Use the options below to customize
|
|||
the way that the kolide server works.
|
||||
`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
var (
|
||||
ctx = context.Background()
|
||||
logger kitlog.Logger
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
config := configManager.LoadConfig()
|
||||
|
||||
logger = kitlog.NewLogfmtLogger(os.Stderr)
|
||||
logger = kitlog.NewContext(logger).With("ts", kitlog.DefaultTimestampUTC)
|
||||
var logger kitlog.Logger
|
||||
{
|
||||
output := os.Stderr
|
||||
if config.Logging.JSON {
|
||||
logger = kitlog.NewJSONLogger(output)
|
||||
} else {
|
||||
logger = kitlog.NewLogfmtLogger(output)
|
||||
}
|
||||
logger = kitlog.NewContext(logger).With("ts", kitlog.DefaultTimestampUTC)
|
||||
}
|
||||
|
||||
var ds kolide.Datastore
|
||||
var err error
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ type OsqueryConfig struct {
|
|||
// LoggingConfig defines configs related to logging
|
||||
type LoggingConfig struct {
|
||||
Debug bool
|
||||
JSON bool
|
||||
DisableBanner bool
|
||||
}
|
||||
|
||||
|
|
@ -129,6 +130,7 @@ func (man Manager) addConfigs() {
|
|||
|
||||
// Logging
|
||||
man.addConfigBool("logging.debug", false)
|
||||
man.addConfigBool("logging.json", false)
|
||||
man.addConfigBool("logging.disable_banner", false)
|
||||
}
|
||||
|
||||
|
|
@ -177,6 +179,7 @@ func (man Manager) LoadConfig() KolideConfig {
|
|||
},
|
||||
Logging: LoggingConfig{
|
||||
Debug: man.getConfigBool("logging.debug"),
|
||||
JSON: man.getConfigBool("logging.json"),
|
||||
DisableBanner: man.getConfigBool("logging.disable_banner"),
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue