Make the log formatter configurable (#371)
* Make the log formatter configurable The change lets us configure the deamon and the plugins to output logs in the JSON format, which is easier to parse/filter by log processing tools. * Add validation for the log-format flag
This commit is contained in:
parent
7c44c2fee1
commit
73169bbace
3 changed files with 29 additions and 3 deletions
|
|
@ -39,7 +39,7 @@ func AuthMethodFromName(n string) AuthMethod {
|
|||
return -1
|
||||
}
|
||||
|
||||
func ConfigStdioLogrus(p SshPiperPlugin, logger *logrus.Logger) {
|
||||
func ConfigStdioLogrus(p SshPiperPlugin, formatter logrus.Formatter, logger *logrus.Logger) {
|
||||
if logger == nil {
|
||||
logger = logrus.StandardLogger()
|
||||
}
|
||||
|
|
@ -50,7 +50,11 @@ func ConfigStdioLogrus(p SshPiperPlugin, logger *logrus.Logger) {
|
|||
logger.SetLevel(lv)
|
||||
|
||||
if tty {
|
||||
logger.SetFormatter(&logrus.TextFormatter{ForceColors: true})
|
||||
if formatter != nil {
|
||||
logger.SetFormatter(formatter)
|
||||
} else {
|
||||
logger.SetFormatter(&logrus.TextFormatter{ForceColors: true})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue