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

feat(swap): Log tracing in rolling log files #155

Merged
merged 5 commits into from
Nov 16, 2024

Conversation

binarybaron
Copy link

@binarybaron binarybaron commented Nov 13, 2024

Logs below DEBUG (network failures, balance warnings, ...) will be written to a log file that'll be deleted daily (24 log files, hourly rotated, deleted daily). All other logs will continue to be written to stdout/stderr and the permanent log file.

@binarybaron
Copy link
Author

binarybaron commented Nov 15, 2024

Compiler error:

error[E0277]: the trait bound `(Filtered<tracing_subscriber::fmt::Layer<Registry, JsonFields, tracing_subscriber::fmt::format::Format<tracing_subscriber::fmt::format::Json, UtcTime<Rfc3339>>, RollingFileAppender>, EnvFilter, Registry>, Filtered<tracing_subscriber::fmt::Layer<Registry, JsonFields, tracing_subscriber::fmt::format::Format<tracing_subscriber::fmt::format::Json, UtcTime<Rfc3339>>, RollingFileAppender>, EnvFilter, Registry>, Filtered<tracing_subscriber::fmt::Layer<_, JsonFields, tracing_subscriber::fmt::format::Format<tracing_subscriber::fmt::format::Json, UtcTime<Rfc3339>>, TauriWriter>, EnvFilter, _>, Filtered<tracing_subscriber::fmt::Layer<_, JsonFields, tracing_subscriber::fmt::format::Format<tracing_subscriber::fmt::format::Json, UtcTime<Rfc3339>>, fn() -> std::io::Stdout {std::io::stdout}>, EnvFilter, _>): __tracing_subscriber_Layer<Registry>` is not satisfied
    --> swap/src/common/tracing_util.rs:83:21
     |
82   |                   .with(
     |                    ---- required by a bound introduced by this call
83   | /                     (
84   | |                         file_layer,
85   | |                         tracing_file_layer,
86   | |                         tauri_layer,
87   | |                         terminal_layer.json().with_filter(env_filtered),
88   | |                     )
     | |_____________________^ the trait `__tracing_subscriber_Layer<Registry>` is not implemented for `(Filtered<Layer<Registry, JsonFields, Format<Json, UtcTime<Rfc3339>>, RollingFileAppender>, EnvFilter, ...>, ..., ..., ...)`
     |
     = help: the following other types implement trait `__tracing_subscriber_Layer<S>`:
               Box<(dyn __tracing_subscriber_Layer<S> + std::marker::Send + std::marker::Sync + 'static)>
               Box<L>
               DynFilterFn<S, F, R>
               EnvFilter
               FilterFn<F>
               Filtered<L, F, S>
               Layered<A, B, S>
               Targets
             and 6 others
note: required by a bound in `tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt::with`
    --> /Users/mohan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-subscriber-0.3.18/src/layer/mod.rs:1503:12
     |
1501 |     fn with<L>(self, layer: L) -> Layered<L, Self>
     |        ---- required by a bound in this associated function
1502 |     where
1503 |         L: Layer<Self>,
     |            ^^^^^^^^^^^ required by this bound in `__tracing_subscriber_SubscriberExt::with`

error[E0599]: no method named `try_init` found for struct `Layered` in the current scope
  --> swap/src/common/tracing_util.rs:90:18
   |
81 | /             tracing_subscriber::registry()
82 | |                 .with(
83 | |                     (
84 | |                         file_layer,
...  |
89 | |                 )
90 | |                 .try_init()?;
   | |_________________-^^^^^^^^
   |
   = note: the full type name has been written to '/Users/mohan/Development/core/target/debug/deps/swap-d5d9befdbb422ae6.long-type-11508068698376379733.txt'
   = note: consider using `--verbose` to print the full type name to the console
help: there is a method `try_into` with a similar name
   |
90 |                 .try_into()?;
   |                  ~~~~~~~~

error[E0277]: the trait bound `(Filtered<tracing_subscriber::fmt::Layer<Registry, JsonFields, tracing_subscriber::fmt::format::Format<tracing_subscriber::fmt::format::Json, UtcTime<Rfc3339>>, RollingFileAppender>, EnvFilter, Registry>, Filtered<tracing_subscriber::fmt::Layer<Registry, JsonFields, tracing_subscriber::fmt::format::Format<tracing_subscriber::fmt::format::Json, UtcTime<Rfc3339>>, RollingFileAppender>, EnvFilter, Registry>, Filtered<tracing_subscriber::fmt::Layer<_, JsonFields, tracing_subscriber::fmt::format::Format<tracing_subscriber::fmt::format::Json, UtcTime<Rfc3339>>, TauriWriter>, EnvFilter, _>, Filtered<tracing_subscriber::fmt::Layer<_, DefaultFields, tracing_subscriber::fmt::format::Format<tracing_subscriber::fmt::format::Full, UtcTime<Rfc3339>>, fn() -> std::io::Stdout {std::io::stdout}>, EnvFilter, _>): __tracing_subscriber_Layer<Registry>` is not satisfied
    --> swap/src/common/tracing_util.rs:95:21
     |
94   |                   .with(
     |                    ---- required by a bound introduced by this call
95   | /                     (
96   | |                         file_layer,
97   | |                         tracing_file_layer,
98   | |                         tauri_layer,
99   | |                         terminal_layer.with_filter(env_filtered),
100  | |                     )
     | |_____________________^ the trait `__tracing_subscriber_Layer<Registry>` is not implemented for `(Filtered<Layer<Registry, JsonFields, Format<Json, UtcTime<Rfc3339>>, RollingFileAppender>, EnvFilter, ...>, ..., ..., ...)`
     |
     = help: the following other types implement trait `__tracing_subscriber_Layer<S>`:
               Box<(dyn __tracing_subscriber_Layer<S> + std::marker::Send + std::marker::Sync + 'static)>
               Box<L>
               DynFilterFn<S, F, R>
               EnvFilter
               FilterFn<F>
               Filtered<L, F, S>
               Layered<A, B, S>
               Targets
             and 6 others
note: required by a bound in `tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt::with`
    --> /Users/mohan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-subscriber-0.3.18/src/layer/mod.rs:1503:12
     |
1501 |     fn with<L>(self, layer: L) -> Layered<L, Self>
     |        ---- required by a bound in this associated function
1502 |     where
1503 |         L: Layer<Self>,
     |            ^^^^^^^^^^^ required by this bound in `__tracing_subscriber_SubscriberExt::with`

error[E0599]: no method named `try_init` found for struct `Layered` in the current scope
   --> swap/src/common/tracing_util.rs:102:18
    |
93  | /             tracing_subscriber::registry()
94  | |                 .with(
95  | |                     (
96  | |                         file_layer,
...   |
101 | |                 )
102 | |                 .try_init()?;
    | |_________________-^^^^^^^^
    |
    = note: the full type name has been written to '/Users/mohan/Development/core/target/debug/deps/swap-d5d9befdbb422ae6.long-type-1263409905811648746.txt'
    = note: consider using `--verbose` to print the full type name to the console
help: there is a method `try_into` with a similar name
    |
102 |                 .try_into()?;
    |                  ~~~~~~~~

Some errors have detailed explanations: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `swap` (lib) due to 4 previous errors

This will fix make it easier to search through logs. Log files will get rotated and deleted regularly. Only the last 24hours will be kept.
@binarybaron binarybaron force-pushed the swap/rolling-tracing-log branch from 0b3d62b to c1cd114 Compare November 16, 2024 17:59
@binarybaron binarybaron marked this pull request as ready for review November 16, 2024 20:53
@binarybaron binarybaron merged commit 3085eee into master Nov 16, 2024
26 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant