plugins-workspace icon indicating copy to clipboard operation
plugins-workspace copied to clipboard

tauri_plugin_log::RotationStrategy::KeepAll does not work as expected on macOS

Open venkr opened this issue 1 year ago • 1 comments

Description: tauri_plugin_log::RotationStrategy::KeepAll seems to only keep the last 2 logs, instead of all logs as promised.

Repro steps:

  • Set up a project using tauri_plugin_log, and the following logger config:
tauri_plugin_log::Builder::default()
        .level(log::LevelFilter::Debug)
        .targets([
            Target::new(TargetKind::Stdout),
            Target::new(TargetKind::LogDir { file_name: None }),
            Target::new(TargetKind::Dispatch(make_sentry_logger())),
        ])
        .rotation_strategy(tauri_plugin_log::RotationStrategy::KeepAll)
        .build(),
  • Visit the logging directory (~/Library/Logs/<AppName>)
  • See the log file(s)
  • Close the app
  • Artificially inflate the size of the current log file to force rotation
  • Relaunch the app

Expected behavior:

  • Whenever a log gets rotated, it should be preserved, along with all previous logs

Actual behavior:

  • Only at most 2 .log files exist at a given time - the most recent log file, and the previous log file. All other older log files are lost.

Tauri info: [✔] Environment - OS: Mac OS 14.4.1 X64 ✔ Xcode Command Line Tools: installed ✔ rustc: 1.76.0 (07dca489a 2024-02-04) ✔ cargo: 1.76.0 (c84b36747 2024-01-18) ✔ rustup: 1.26.0 (5af9b9484 2023-04-05) ✔ Rust toolchain: stable-aarch64-apple-darwin (default) - node: 20.10.0 - pnpm: 8.11.0 - yarn: 1.22.19 - npm: 8.1.2

[-] Packages - tauri [RUST]: 2.0.0-beta.12 - tauri-build [RUST]: 2.0.0-beta.10 - wry [RUST]: 0.37.0 - tao [RUST]: 0.26.0 - tauri-cli [RUST]: 2.0.0-beta.12 - @tauri-apps/api [NPM]: 2.0.0-beta.0 - @tauri-apps/cli [NPM]: 2.0.0-beta.3

[-] App - build-type: bundle - CSP: unset - frontendDist: http://localhost:5173/ - devUrl: http://localhost:5173/ - framework: React - bundler: Vite

venkr avatar May 31 '24 18:05 venkr

With the latest versions, it works as expected for me.

  • macOS: 14.5 (23F79)
  • tauri: 2.0.0-beta.24
  • tauri-plugin-log: 2.0.0-beta.8
tauri_plugin_log::Builder::new()
    .level(LevelFilter::Debug)
    .rotation_strategy(RotationStrategy::KeepAll)
    .max_file_size(10) // artificially low file size to exemplify
    .targets([
        Target::new(TargetKind::LogDir { file_name: None }),
    ])
    .build()

Result: CleanShot 2024-07-17 at 13 49 02@2x

gabeins avatar Jul 17 '24 11:07 gabeins