mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-08-04 04:10:32 +02:00
feat(birdnet-go): add LOG_MAX_SIZE_MB and LOG_MAX_AGE_DAYS options to manage log storage
Add addon options to control birdnet-go log file rotation: - LOG_MAX_SIZE_MB (default: 50): maximum size per log file before rotation - LOG_MAX_AGE_DAYS (default: 7): maximum days to retain old log files On startup, the addon: 1. Configures birdnet-go's logging.file_output settings in config.yaml 2. Sets max_rotated_files to 3 and enables compression 3. Trims existing log files exceeding the configured age Fixes #1922
This commit is contained in:
committed by
GitHub
parent
e09e2afb2c
commit
71bb8b5130
@@ -1,4 +1,6 @@
|
||||
## nightly-20260525 (26-05-2026)
|
||||
- Add LOG_MAX_SIZE_MB and LOG_MAX_AGE_DAYS addon options to manage log storage size
|
||||
- Automatically trim log files exceeding configured age on startup
|
||||
- Minor bugs fixed
|
||||
## nightly-20260511-414-2 (22-05-2026)
|
||||
- Minor bugs fixed
|
||||
|
||||
@@ -86,6 +86,8 @@ name: Birdnet-go
|
||||
options:
|
||||
env_vars: []
|
||||
BIRDSONGS_FOLDER: /config/clips
|
||||
LOG_MAX_SIZE_MB: 50
|
||||
LOG_MAX_AGE_DAYS: 7
|
||||
homeassistant_microphone: false
|
||||
panel_admin: false
|
||||
panel_icon: mdi:bird
|
||||
@@ -104,6 +106,8 @@ schema:
|
||||
- name: match(^[A-Za-z0-9_]+$)
|
||||
value: str?
|
||||
BIRDSONGS_FOLDER: str?
|
||||
LOG_MAX_SIZE_MB: int(1,1000)?
|
||||
LOG_MAX_AGE_DAYS: int(1,365)?
|
||||
TZ: str?
|
||||
cifsdomain: str?
|
||||
cifspassword: str?
|
||||
|
||||
@@ -100,3 +100,26 @@ bashio::log.info "Correcting configuration for defaults"
|
||||
# Update database location in config files
|
||||
yq -i -y ".output.sqlite.path = \"/config/birdnet.db\"" "$CONFIG_LOCATION"
|
||||
bashio::log.info "... database is located in /config/birdnet.db"
|
||||
|
||||
####################
|
||||
# Log Management
|
||||
####################
|
||||
LOG_MAX_SIZE_MB="$(bashio::config "LOG_MAX_SIZE_MB")"
|
||||
LOG_MAX_SIZE_MB="${LOG_MAX_SIZE_MB:-50}"
|
||||
LOG_MAX_AGE_DAYS="$(bashio::config "LOG_MAX_AGE_DAYS")"
|
||||
LOG_MAX_AGE_DAYS="${LOG_MAX_AGE_DAYS:-7}"
|
||||
|
||||
bashio::log.info "Configuring log rotation: max ${LOG_MAX_SIZE_MB}MB per file, max ${LOG_MAX_AGE_DAYS} days retention"
|
||||
|
||||
# Configure log rotation in birdnet-go config
|
||||
yq -i -y ".logging.file_output.max_size = ${LOG_MAX_SIZE_MB}" "$CONFIG_LOCATION"
|
||||
yq -i -y ".logging.file_output.max_age = ${LOG_MAX_AGE_DAYS}" "$CONFIG_LOCATION"
|
||||
yq -i -y ".logging.file_output.max_rotated_files = 3" "$CONFIG_LOCATION"
|
||||
yq -i -y ".logging.file_output.compress = true" "$CONFIG_LOCATION"
|
||||
|
||||
# Trim existing log files that exceed the configured max age
|
||||
LOG_DIR="/config/logs"
|
||||
if [ -d "$LOG_DIR" ]; then
|
||||
bashio::log.info "Trimming log files older than ${LOG_MAX_AGE_DAYS} days in ${LOG_DIR}"
|
||||
find "$LOG_DIR" -type f -name "*.log*" -mtime +"$LOG_MAX_AGE_DAYS" -delete 2>/dev/null || true
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user