FLAGS=none has no effect on log flags #4256

Closed
opened 2025-11-02 05:44:02 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @samangh on GitHub (Nov 6, 2019).

  • Gitea version (or commit ref): 1.9.5 built with GNU Make 4.1, go1.12.11 : bindata, sqlite, sqlite_unlock_notify
  • Operating system: Debian Stable
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant

Description

I'm trying to prevent gitea from adding data/time/etc log flags to its console output. This is becuase the console output is automatically sent to syslog when using systemd to start gitea, and syslog adds its own date/time stamps.

This should be doable by setting log.console.FLAGS to none according to the config cheat sheet. However, setting log.console.FLAGS to none as no effect and console logs are still shown with the default stdflags stuff. Setting log.console.FLAGS to other values seem to work though (for example level or date work as expected).

Relevant config:

[log]
MODE      = console,file
ROOT_PATH = /home/git/gitea/log
COLORIZE  = false

; Put all router-related suff in files
ROUTER   = file
REDIRECT_MACARON_LOG = true

[log.console]
; When using systemd, the console output is sent to syslog.  So we
; don't need the data, time, etc as that is already in syslog.
FLAGS = "none"

Example output on syslog:

Nov  5 17:06:04 server gitea[8484]: 2019/11/05 17:06:04 ...dules/setting/log.go:269:newLogService() [I] Gitea Log Mode: Console(Console:info)
Nov  5 17:06:04 server gitea[8484]: 2019/11/05 17:06:04 ...dules/setting/log.go:269:newLogService() [I] Gitea Log Mode: File(File:info)
Nov  5 17:06:04 server gitea[8484]: 2019/11/05 17:06:04 ...dules/setting/log.go:178:generateNamedLogger() [I] Macaron Log: File(file:info)
Nov  5 17:06:04 server gitea[8484]: 2019/11/05 17:06:04 ...dules/setting/log.go:178:generateNamedLogger() [I] Router Log: File(file:info)
Nov  5 17:06:04 server gitea[8484]: 2019/11/05 17:06:04 ...les/setting/cache.go:42:newCacheService() [I] Cache Service Enabled
Nov  5 17:06:04 server gitea[8484]: 2019/11/05 17:06:04 ...s/setting/session.go:45:newSessionService() [I] Session Service Enabled
Originally created by @samangh on GitHub (Nov 6, 2019). - Gitea version (or commit ref): 1.9.5 built with GNU Make 4.1, go1.12.11 : bindata, sqlite, sqlite_unlock_notify - Operating system: Debian Stable - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant ## Description I'm trying to prevent gitea from adding data/time/etc log flags to its console output. This is becuase the console output is automatically sent to syslog when using systemd to start gitea, and syslog adds its own date/time stamps. This should be doable by setting `log.console.FLAGS` to `none` according to the [config cheat sheet](https://docs.gitea.io/en-us/config-cheat-sheet/). However, setting `log.console.FLAGS` to `none` as no effect and console logs are still shown with the default `stdflags` stuff. Setting `log.console.FLAGS` to other values seem to work though (for example `level` or `date` work as expected). Relevant config: ```ini [log] MODE = console,file ROOT_PATH = /home/git/gitea/log COLORIZE = false ; Put all router-related suff in files ROUTER = file REDIRECT_MACARON_LOG = true [log.console] ; When using systemd, the console output is sent to syslog. So we ; don't need the data, time, etc as that is already in syslog. FLAGS = "none" ``` Example output on syslog: ``` Nov 5 17:06:04 server gitea[8484]: 2019/11/05 17:06:04 ...dules/setting/log.go:269:newLogService() [I] Gitea Log Mode: Console(Console:info) Nov 5 17:06:04 server gitea[8484]: 2019/11/05 17:06:04 ...dules/setting/log.go:269:newLogService() [I] Gitea Log Mode: File(File:info) Nov 5 17:06:04 server gitea[8484]: 2019/11/05 17:06:04 ...dules/setting/log.go:178:generateNamedLogger() [I] Macaron Log: File(file:info) Nov 5 17:06:04 server gitea[8484]: 2019/11/05 17:06:04 ...dules/setting/log.go:178:generateNamedLogger() [I] Router Log: File(file:info) Nov 5 17:06:04 server gitea[8484]: 2019/11/05 17:06:04 ...les/setting/cache.go:42:newCacheService() [I] Cache Service Enabled Nov 5 17:06:04 server gitea[8484]: 2019/11/05 17:06:04 ...s/setting/session.go:45:newSessionService() [I] Session Service Enabled ```
GiteaMirror added the type/bug label 2025-11-02 05:44:02 -06:00
Author
Owner

@zeripath commented on GitHub (Nov 6, 2019):

Damn. The problem lies here:

0109229928/modules/log/flags.go (L53-L64)

Which interacts with lines 44-46 here:

0109229928/modules/log/writer.go (L37-L53)

Flags should be returned as -1 if none.

@zeripath commented on GitHub (Nov 6, 2019): Damn. The problem lies here: https://github.com/go-gitea/gitea/blob/0109229928d8603ebedc2364943538f788635370/modules/log/flags.go#L53-L64 Which interacts with lines 44-46 here: https://github.com/go-gitea/gitea/blob/0109229928d8603ebedc2364943538f788635370/modules/log/writer.go#L37-L53 Flags should be returned as -1 if none.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4256