Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Logger not respecting log level #2262

Open
vr7bd opened this issue Jan 5, 2025 · 0 comments
Open

[bug] Logger not respecting log level #2262

vr7bd opened this issue Jan 5, 2025 · 0 comments
Labels
bug Something isn't working plugin: log

Comments

@vr7bd
Copy link

vr7bd commented Jan 5, 2025

Describe the bug

I am currently trying to use the logging plugin that Tauri provides. I've followed the guide and have set it up with following lines

tauri::Builder::default()
    .plugin(
        tauri_plugin_log::Builder::new()
            .level(log::LevelFilter::Info)
            .target(tauri_plugin_log::Target::new(
                tauri_plugin_log::TargetKind::LogDir {
                    file_name: Some("logs".to_string()),
                },
            ))
            .max_file_size(50_000_000)
            .rotation_strategy(tauri_plugin_log::RotationStrategy::KeepAll)
            .timezone_strategy(tauri_plugin_log::TimezoneStrategy::UseLocal)
            .build(),
    )

I've also installed log = "0.4" as I intend to use the logger only on the rust side.

However, when I open $currentUser/Library/Logs/$app-identifier/logs.log, I'm seeing trace logs too.

[2025-01-06][00:40:26][TRACE][tao::platform_impl::platform::app_delegate] Triggered `applicationDidFinishLaunching`
[2025-01-06][00:40:26][TRACE][tao::platform_impl::platform::window] Creating new window
[2025-01-06][00:40:26][TRACE][tao::platform_impl::platform::view] Triggered `viewDidMoveToWindow`
[2025-01-06][00:40:26][TRACE][tao::platform_impl::platform::view] Completed `viewDidMoveToWindow`
[2025-01-06][00:40:26][TRACE][tao::platform_impl::platform::view] Triggered `validAttributesForMarkedText`
[2025-01-06][00:40:26][TRACE][tao::platform_impl::platform::view] Completed `validAttributesForMarkedText`
[2025-01-06][00:40:26][TRACE][tao::platform_impl::platform::view] Triggered `validAttributesForMarkedText`
[2025-01-06][00:40:26][TRACE][tao::platform_impl::platform::view] Completed `validAttributesForMarkedText`

I'm can confirm that when I use log::info! I'm seeing it appear in the file. I have also tried setting the log level to Trace and Error in case there is some issue regarding enum values. I'm still keep getting trace logs which leads to me to the conclusion that the log level is not being respected.

Reproduction

No response

Expected behavior

The log file in the specified folder should only contain logs greater than or equal to the specified level.

Full tauri info output

[✔] Environment
    - OS: Mac OS 15.2.0 arm64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.83.0 (90b35a623 2024-11-26)
    ✔ cargo: 1.83.0 (5ffbef321 2024-10-29)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 20.11.0
    - pnpm: 9.15.0
    - npm: 10.2.4

[-] Packages
    - tauri 🦀: 2.2.0
    - tauri-build 🦀: 2.0.4
    - wry 🦀: 0.48.0
    - tao 🦀: 0.31.1
    - @tauri-apps/api : 2.2.0
    - @tauri-apps/cli : 2.2.2

[-] Plugins
    - tauri-plugin-dialog 🦀: 2.2.0
    - @tauri-apps/plugin-dialog : 2.2.0
    - tauri-plugin-fs 🦀: 2.2.0
    - @tauri-apps/plugin-fs : 2.2.0
    - tauri-plugin-log 🦀: 2.2.0
    - @tauri-apps/plugin-log : 2.2.0
    - tauri-plugin-shell 🦀: 2.2.0
    - @tauri-apps/plugin-shell : 2.2.0

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../build
    - devUrl: http://localhost:1420/
    - framework: Svelte
    - bundler: Vite

Stack trace

No response

Additional context

Idk if this helps but I'm seeing the trace logs on my terminal when I run pnpm tauri dev. Shouldn't it not show those logs on stdout as I've configured the logger target to only be LogsDir?

@FabianLars FabianLars transferred this issue from tauri-apps/tauri Jan 5, 2025
@FabianLars FabianLars added bug Something isn't working plugin: log labels Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working plugin: log
Projects
None yet
Development

No branches or pull requests

2 participants