Files
PX4-Autopilot/docs
Julian Oes f9fdda1a29 feat(logger): rework log rotation and cleanup
Make the logger practical on small flash storage (e.g. 128 MB W25N
NAND) while keeping the existing SD-card behaviour sensible.

- Move cleanup from boot to log start so logs can be downloaded via
  MAVLink FTP before deletion.
- Delete individual .ulg files (oldest first) instead of whole
  directories, prioritising the naming scheme not currently in use
  (session dirs vs date dirs).
- Add SDLOG_MAX_SIZE (new, default 1024 MB): maximum size of a single
  log file. When reached, the log rotates to a new file. The value is
  also reserved as headroom in the cleanup threshold.
- Add SDLOG_ROTATE (new, default 90): maximum disk usage percentage.
  Cleanup guarantees (100 - SDLOG_ROTATE)% free at all times, even
  during writing of a new log file. 0 disables space-based cleanup,
  100 allows filling the disk.
- Repurpose SDLOG_DIRS_MAX as an orthogonal directory-count cap
  (default 0 = disabled). Useful for capping log usage by count
  independent of disk size, e.g. in SITL.
- Drop the implicit ~300 MB free-space floor that used to fire even
  with SDLOG_DIRS_MAX=0; space is now governed entirely by
  SDLOG_ROTATE + SDLOG_MAX_SIZE.
- Split pure parsing helpers into util_parse.{h,cpp} and add unit
  tests (loggerUtilTest.cpp).
- Simplify get_log_time to rely on clock_gettime (set by the GPS
  driver); safer string handling in directory parsing.
- Reset _total_written in LogFileBuffer::reset() so callers reading
  get_total_written() between stop and start don't see stale counts.

Sponsored by CubePilot.
2026-04-23 10:30:14 +12:00
..
2026-04-21 08:50:19 +00:00

PX4 User Guide

This repo contains the source code for the PX4 User Guide.

Note

Contributions and Translations to this guide are very welcome!