From 37116739cc13ba6330525e48fffd71d79bb98c7d Mon Sep 17 00:00:00 2001 From: genofire Date: Fri, 18 Sep 2020 14:02:41 +0200 Subject: [PATCH] improve logging support --- README.md | 4 ++++ defaults/main.yml | 3 +++ templates/gitea.ini.j2 | 11 ++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4286330..5567511 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,10 @@ The following code has been tested with Debian 8, it should work on Ubuntu as we * `gitea_autowatch_on_change`: Enable this to make users watch a repository after their first commit to it (Default: `true`) * `gitea_show_mailstones_dashboard`: Enable this to show the milestones dashboard page - a view of all the user’s milestones (Default: `true`) +### Log configuration +* `gitea_log_systemd` Disable logging into `file`, use systemd-journald +* `gitea_log_only_warning` Log only warnings or above, no http access or sql logging (Default: `true`) + ### Fail2Ban configuration If enabled, this will deploy a fail2ban filter and jail config for Gitea as described in the [Gitea Documentation](https://docs.gitea.io/en-us/fail2ban-setup/). diff --git a/defaults/main.yml b/defaults/main.yml index c35b4d9..7757cb4 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -72,6 +72,9 @@ gitea_mailer_user: "" gitea_mailer_password: "" gitea_mailer_type: smtp +gitea_log_systemd: false +gitea_log_only_warning: true + gitea_fail2ban_enabled: false gitea_fail2ban_jail_maxretry: 10 gitea_fail2ban_jail_findtime: 3600 diff --git a/templates/gitea.ini.j2 b/templates/gitea.ini.j2 index a10939d..2146923 100644 --- a/templates/gitea.ini.j2 +++ b/templates/gitea.ini.j2 @@ -188,12 +188,21 @@ PATH = {{ gitea_home }}/data/attachments ROOT_PATH = {{ gitea_home }}/log ; Either "console", "file", "conn", "smtp" or "database", default is "console" ; Use comma to separate multiple modes, e.g. "console, file" -MODE = file +{% if gitea_log_systemd %} +MODE = console +{% else %} +MODE = file +{% endif %} ; Buffer length of the channel, keep it as it is if you don't know what it is. BUFFER_LEN = 10000 ; Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "Trace" +{% if gitea_log_only_warning %} +LEVEL = Warn +REDIRECT_MACARON_LOG = true +{% else %} LEVEL = {{ gitea_log_level }} REDIRECT_MACARON_LOG = false +{% endif %} [oauth2] ENABLE = {{ gitea_oauth2_enabled }}