Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reminder for no more logs to console #22282

Merged
merged 5 commits into from
Jan 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 12 additions & 17 deletions modules/setting/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,6 @@ func newRouterLogService() {
}

func newLogService() {
log.Info("Gitea v%s%s", AppVer, AppBuiltWith)

options := newDefaultLogOptions()
options.bufferLength = Cfg.Section("log").Key("BUFFER_LEN").MustInt64(10000)
EnableSSHLog = Cfg.Section("log").Key("ENABLE_SSH_LOG").MustBool(false)
Expand All @@ -297,24 +295,14 @@ func newLogService() {
sections := strings.Split(Cfg.Section("log").Key("MODE").MustString("console"), ",")

useConsole := false
for i := 0; i < len(sections); i++ {
sections[i] = strings.TrimSpace(sections[i])
if sections[i] == "console" {
useConsole = true
}
}

if !useConsole {
err := log.DelLogger("console")
if err != nil {
log.Fatal("DelLogger: %v", err)
}
}

for _, name := range sections {
if len(name) == 0 {
name = strings.TrimSpace(name)
if name == "" {
continue
}
if name == "console" {
useConsole = true
}

sec, err := Cfg.GetSection("log." + name + ".default")
if err != nil {
Expand All @@ -336,6 +324,13 @@ func newLogService() {

AddLogDescription(log.DEFAULT, &description)

if !useConsole {
log.Info("According to the configuration, subsequent logs will not be printed to the console")
if err := log.DelLogger("console"); err != nil {
log.Fatal("Cannot delete console logger: %v", err)
}
}

// Finally redirect the default golog to here
golog.SetFlags(0)
golog.SetPrefix("")
Expand Down
1 change: 1 addition & 0 deletions routers/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func GlobalInitInstalled(ctx context.Context) {
log.Info("Log path: %s", setting.LogRootPath)
log.Info("Configuration file: %s", setting.CustomConf)
log.Info("Run Mode: %s", util.ToTitleCase(setting.RunMode))
log.Info("Gitea v%s%s", setting.AppVer, setting.AppBuiltWith)

// Setup i18n
translation.InitLocales(ctx)
Expand Down