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
|
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
|
|
@ -11,6 +12,7 @@ type PluginTemplate struct {
|
|||
Name string
|
||||
Usage string
|
||||
Flags []cli.Flag
|
||||
LogFormatter logrus.Formatter
|
||||
CreateConfig func(c *cli.Context) (*SshPiperPluginConfig, error)
|
||||
}
|
||||
|
||||
|
|
@ -42,7 +44,7 @@ func CreateAndRunPluginTemplate(t *PluginTemplate) {
|
|||
return err
|
||||
}
|
||||
|
||||
ConfigStdioLogrus(p, nil)
|
||||
ConfigStdioLogrus(p, t.LogFormatter, nil)
|
||||
return p.Serve()
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue