Add ability to disable logging output
This commit is contained in:
parent
d9d6cdca6d
commit
715eb86cec
3 changed files with 8 additions and 1 deletions
|
@ -258,6 +258,7 @@ func setup() {
|
||||||
if opts.Logging.Output != "" {
|
if opts.Logging.Output != "" {
|
||||||
|
|
||||||
chk := map[string]bool{
|
chk := map[string]bool{
|
||||||
|
"none": true,
|
||||||
"stdout": true,
|
"stdout": true,
|
||||||
"stderr": true,
|
"stderr": true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,9 @@ var startCmd = &cobra.Command{
|
||||||
Short: "Start the database and http server",
|
Short: "Start the database and http server",
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
|
|
||||||
|
if opts.Logging.Output != "none" {
|
||||||
fmt.Print(logo)
|
fmt.Print(logo)
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
|
|
@ -18,6 +18,8 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"io/ioutil"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -230,6 +232,8 @@ func (l *Logger) SetFormat(v string) {
|
||||||
// SetOutput sets the logging output of the logger instance.
|
// SetOutput sets the logging output of the logger instance.
|
||||||
func (l *Logger) SetOutput(v string) {
|
func (l *Logger) SetOutput(v string) {
|
||||||
switch v {
|
switch v {
|
||||||
|
case "none":
|
||||||
|
l.Out = ioutil.Discard
|
||||||
case "stdout":
|
case "stdout":
|
||||||
l.Out = os.Stdout
|
l.Out = os.Stdout
|
||||||
case "stderr":
|
case "stderr":
|
||||||
|
|
Loading…
Reference in a new issue