mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 14:37:51 +01:00
Remove the default console logger when it is not set in the configuration (#602)
* Remove the default console logger when it is not set in the configuration * Added comment to new function (lint failure) * update based on PR comments (code style) * code style fix (thanks bkcsoft) * check if logger exists based on the l.outputs (like in l.DelLogger) instead of adapter, otherwise panic when reinstalling gitea (since the output adapter still exist, without outputs)
This commit is contained in:
parent
d1006150fb
commit
8c2c7b802f
@ -39,6 +39,17 @@ func NewLogger(bufLen int64, mode, config string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DelLogger removes loggers that are for the given mode
|
||||||
|
func DelLogger(mode string) error {
|
||||||
|
for _, l := range loggers {
|
||||||
|
if _, ok := l.outputs[mode]; ok {
|
||||||
|
return l.DelLogger(mode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Trace("Log adapter %s not found, no need to delete", mode)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// NewGitLogger create a logger for git
|
// NewGitLogger create a logger for git
|
||||||
// FIXME: use same log level as other loggers.
|
// FIXME: use same log level as other loggers.
|
||||||
func NewGitLogger(logPath string) {
|
func NewGitLogger(logPath string) {
|
||||||
|
@ -895,6 +895,16 @@ func newLogService() {
|
|||||||
LogModes = strings.Split(Cfg.Section("log").Key("MODE").MustString("console"), ",")
|
LogModes = strings.Split(Cfg.Section("log").Key("MODE").MustString("console"), ",")
|
||||||
LogConfigs = make([]string, len(LogModes))
|
LogConfigs = make([]string, len(LogModes))
|
||||||
|
|
||||||
|
useConsole := false
|
||||||
|
for _, mode := range LogModes {
|
||||||
|
if mode == "console" {
|
||||||
|
useConsole = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!useConsole) {
|
||||||
|
log.DelLogger("console")
|
||||||
|
}
|
||||||
|
|
||||||
for i, mode := range LogModes {
|
for i, mode := range LogModes {
|
||||||
mode = strings.TrimSpace(mode)
|
mode = strings.TrimSpace(mode)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user