Added possible fix for logging when nothing is set
This commit is contained in:
parent
9e635ea54e
commit
5e7c9b9eb9
3 changed files with 15 additions and 13 deletions
|
@ -76,13 +76,13 @@ log:
|
|||
path: <rootpath>logs
|
||||
# Whether to show any logging at all or none
|
||||
enabled: true
|
||||
# Where the error log should go. Possible values are stdout, file or off to disable error logging.
|
||||
# Where the error log should go. Possible values are stdout, stderr, file or off to disable error logging.
|
||||
errors: "stdout"
|
||||
# Where the normal log should go. Possible values are stdout, file or off to disable standard logging.
|
||||
# Where the normal log should go. Possible values are stdout, stderr, file or off to disable standard logging.
|
||||
standard: "stdout"
|
||||
# Whether or not to log database queries. Useful for debugging. Possible values are stdout, file or off to disable database logging.
|
||||
# Whether or not to log database queries. Useful for debugging. Possible values are stdout, stderr, file or off to disable database logging.
|
||||
database: "off"
|
||||
# Whether to log http requests or not. Possible values are stdout, file or off to disable http logging.
|
||||
# Whether to log http requests or not. Possible values are stdout, stderr, file or off to disable http logging.
|
||||
http: "stdout"
|
||||
# Echo has its own logging which usually is unnessecary, which is why it is disabled by default. Possible values are stdout, file or off to disable standard logging.
|
||||
# Echo has its own logging which usually is unnessecary, which is why it is disabled by default. Possible values are stdout, stderr, file or off to disable standard logging.
|
||||
echo: "off"
|
|
@ -103,21 +103,20 @@ mailer:
|
|||
queuelength: 100
|
||||
# The timeout in seconds after which the current open connection to the mailserver will be closed.
|
||||
queuetimeout: 30
|
||||
|
||||
|
||||
log:
|
||||
# A folder where all the logfiles should go.
|
||||
path: service.rootpath + "/logs"
|
||||
path: <rootpath>logs
|
||||
# Whether to show any logging at all or none
|
||||
enabled: true
|
||||
# Where the error log should go. Possible values are stdout, file or off to disable error logging.
|
||||
# Where the error log should go. Possible values are stdout, stderr, file or off to disable error logging.
|
||||
errors: "stdout"
|
||||
# Where the normal log should go. Possible values are stdout, file or off to disable standard logging.
|
||||
# Where the normal log should go. Possible values are stdout, stderr, file or off to disable standard logging.
|
||||
standard: "stdout"
|
||||
# Whether or not to log database queries. Useful for debugging. Possible values are stdout, file or off to disable database logging.
|
||||
# Whether or not to log database queries. Useful for debugging. Possible values are stdout, stderr, file or off to disable database logging.
|
||||
database: "off"
|
||||
# Whether to log http requests or not. Possible values are stdout, file or off to disable http logging.
|
||||
# Whether to log http requests or not. Possible values are stdout, stderr, file or off to disable http logging.
|
||||
http: "stdout"
|
||||
# Echo has its own logging which usually is unnessecary, which is why it is disabled by default. Possible values are stdout, file or off to disable standard logging.
|
||||
# Echo has its own logging which usually is unnessecary, which is why it is disabled by default. Possible values are stdout, stderr, file or off to disable standard logging.
|
||||
echo: "off"
|
||||
|
||||
```
|
||||
|
|
|
@ -83,6 +83,7 @@ func InitLogger() {
|
|||
|
||||
// GetLogWriter returns the writer to where the normal log goes, depending on the config
|
||||
func GetLogWriter(logfile string) (writer io.Writer) {
|
||||
writer = os.Stderr // Set the default case to prevent nil pointer panics
|
||||
switch viper.GetString("log." + logfile) {
|
||||
case "file":
|
||||
f, err := os.OpenFile(viper.GetString("log.path")+"/"+logfile+".log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
|
@ -91,6 +92,8 @@ func GetLogWriter(logfile string) (writer io.Writer) {
|
|||
}
|
||||
writer = f
|
||||
break
|
||||
case "stderr":
|
||||
writer = os.Stderr
|
||||
case "stdout":
|
||||
default:
|
||||
writer = os.Stdout
|
||||
|
|
Loading…
Reference in a new issue