1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-07-24 20:19:39 +02:00

feat: add a EXCLUSION to the logger (#8212)

This feature is intended to help reduce noisy logs generated by routine Kubernetes probes and Prometheus scraping. While logs are essential, these specific requests (e.g., to /metrics and /api/healthz) generally don't provide useful information and tend to clutter the output.

The goal is to introduce functionality that effectively acts as the inverse of the existing EXPRESSION mode—allowing logging to be excluded based on a condition, rather than included.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8212
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: zokki <zokki.softwareschmiede@gmail.com>
Co-committed-by: zokki <zokki.softwareschmiede@gmail.com>
This commit is contained in:
zokki 2025-07-04 00:08:23 +02:00 committed by Gusted
parent b669564f39
commit 72620db8df
9 changed files with 100 additions and 0 deletions

View file

@ -44,6 +44,7 @@ func TestLogConfigDefault(t *testing.T) {
"BufferLen": 10000,
"Colorize": false,
"Expression": "",
"Exclusion": "",
"Flags": "stdflags",
"Level": "info",
"Prefix": "",
@ -83,6 +84,7 @@ logger.xorm.MODE =
"BufferLen": 10000,
"Colorize": false,
"Expression": "",
"Exclusion": "",
"Flags": "stdflags",
"Level": "info",
"Prefix": "",
@ -121,6 +123,7 @@ MODE = console
"BufferLen": 10000,
"Colorize": false,
"Expression": "",
"Exclusion": "",
"Flags": "stdflags",
"Level": "info",
"Prefix": "",
@ -168,6 +171,7 @@ ACCESS = file
"BufferLen": 10000,
"Colorize": false,
"Expression": "",
"Exclusion": "",
"Flags": "stdflags",
"Level": "info",
"Prefix": "",
@ -191,6 +195,7 @@ ACCESS = file
"BufferLen": 10000,
"Colorize": false,
"Expression": "",
"Exclusion": "",
"Flags": "none",
"Level": "info",
"Prefix": "",
@ -257,6 +262,7 @@ STDERR = true
"BufferLen": 10000,
"Colorize": false,
"Expression": "",
"Exclusion": "",
"Flags": "stdflags",
"Level": "warn",
"Prefix": "",
@ -270,6 +276,7 @@ STDERR = true
"BufferLen": 10000,
"Colorize": false,
"Expression": "",
"Exclusion": "",
"Flags": "stdflags",
"Level": "error",
"Prefix": "",
@ -287,6 +294,7 @@ STDERR = true
"BufferLen": 10000,
"Colorize": false,
"Expression": "",
"Exclusion": "",
"Flags": "none",
"Level": "warn",
"Prefix": "",
@ -323,6 +331,7 @@ MODE = file
LEVEL = error
STACKTRACE_LEVEL = fatal
EXPRESSION = filter
EXCLUSION = not
FLAGS = medfile
PREFIX = "[Prefix] "
FILE_NAME = file-xxx.log
@ -341,6 +350,7 @@ COMPRESSION_LEVEL = 4
"BufferLen": 10,
"Colorize": false,
"Expression": "",
"Exclusion": "",
"Flags": "stdflags",
"Level": "info",
"Prefix": "",
@ -360,6 +370,7 @@ COMPRESSION_LEVEL = 4
"BufferLen": 10,
"Colorize": false,
"Expression": "filter",
"Exclusion": "not",
"Flags": "medfile",
"Level": "error",
"Prefix": "[Prefix] ",