1
0
mirror of https://github.com/Mailu/Mailu.git synced 2025-03-03 14:52:36 +02:00
3235: Tweaks to logging r=mergify[bot] a=nextgens

## What type of PR?

enhancement

## What does this PR do?

Make the default ``LOG_LEVEL=INFO`` ; ensure that admin does not log the access log unless it's set to ``DEBUG``
This ensures we see the authentication related messages.

### Related issue(s)

## Prerequisites
Before we can consider review and merge, please make sure the following list is done and checked.
If an entry in not applicable, you can check it or remove it from the list.

- [ ] In case of feature or enhancement: documentation updated accordingly
- [ ] Unless it's docs or a minor change: add [changelog](https://mailu.io/master/contributors/workflow.html#changelog) entry file.


Co-authored-by: Florent Daigniere <nextgens@freenetproject.org>
This commit is contained in:
bors-mailu[bot] 2024-05-10 11:16:50 +00:00 committed by GitHub
commit 935266bc65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View File

@ -11,7 +11,14 @@ import logging
import hmac
class NoPingFilter(logging.Filter):
skipAccessLogs = False
def __init__(self, filterAccessLogs=False):
self.skipAccessLogs = filterAccessLogs
def filter(self, record):
if self.skipAccessLogs and record.args['r'].endswith(' HTTP/1.1'):
return False
if record.args['r'].endswith(' /ping HTTP/1.1'):
return False
if record.args['r'].endswith(' /internal/rspamd/local_domains HTTP/1.1'):
@ -24,7 +31,7 @@ class Logger(glogging.Logger):
# Add filters to Gunicorn logger
logger = logging.getLogger("gunicorn.access")
logger.addFilter(NoPingFilter())
logger.addFilter(NoPingFilter(logger.getEffectiveLevel()>logging.DEBUG))
def create_app_from_config(config):
""" Create a new application based on the given configuration

View File

@ -178,7 +178,7 @@ REAL_IP_FROM={{ real_ip_from }}
REJECT_UNLISTED_RECIPIENT={{ reject_unlisted_recipient }}
# Log level threshold in start.py (value: CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET)
LOG_LEVEL=WARNING
LOG_LEVEL=INFO
# Timezone for the Mailu containers. See this link for all possible values https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
TZ=Etc/UTC