diff --git a/README.md b/README.md index c47f138fbf..78d9cad1f7 100644 --- a/README.md +++ b/README.md @@ -164,7 +164,7 @@ If you want to do add the repository manually, please follow the procedure highl ![smb][smb-badge] ![localdisks][localdisks-badge] -✓ ![image](https://api.iconify.design/mdi/bird.svg) [Birdnet-go](birdnet-go/) : Realtime BirdNET soundscape analyzer +✓ ![image](https://api.iconify.design/mdi/bird.svg) [Birdnet-go](birdnet-go/) : Realtime BirdNET and Battybirdnet soundscape analyzer   ![Version](https://img.shields.io/badge/dynamic/yaml?label=Version&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2Fbirdnet-go%2Fconfig.yaml) ![Update](https://img.shields.io/badge/dynamic/json?label=Updated&query=%24.last_update&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2Fbirdnet-go%2Fupdater.json) diff --git a/birdnet-go/CHANGELOG.md b/birdnet-go/CHANGELOG.md index 639f5289e3..d7a86bc0bf 100644 --- a/birdnet-go/CHANGELOG.md +++ b/birdnet-go/CHANGELOG.md @@ -1,9 +1,12 @@ ## nightly-20260525-2 (26-05-2026) - Suppress noisy startup logs: silence `chmod /dev/snd` errors on the read-only HA mount, and hide unavailable ALSA plugins (JACK, OSS, dsnoop) from device enumeration so libjack and pcm_oss/dsnoop probes no longer print at launch. ALSA overrides are written to `/root/.asoundrc` (since `/etc/asound.conf` is read-only in this environment). - Allow advanced users to override the ALSA config by dropping a custom `asound.conf` into the addon config folder. +- 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 ## nightly-20260525 (26-05-2026) - Minor bugs fixed + ## nightly-20260511-414-2 (22-05-2026) - Minor bugs fixed diff --git a/birdnet-go/config.yaml b/birdnet-go/config.yaml index a60d506cfd..5c5d5ad94a 100644 --- a/birdnet-go/config.yaml +++ b/birdnet-go/config.yaml @@ -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? diff --git a/birdnet-go/rootfs/etc/cont-init.d/01-structure.sh b/birdnet-go/rootfs/etc/cont-init.d/01-structure.sh index 5514bd07c7..dcf44ecd81 100755 --- a/birdnet-go/rootfs/etc/cont-init.d/01-structure.sh +++ b/birdnet-go/rootfs/etc/cont-init.d/01-structure.sh @@ -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