Skip to content

Commit

Permalink
Update logging
Browse files Browse the repository at this point in the history
  • Loading branch information
TTWNO committed Jun 13, 2024
1 parent 91e0d20 commit cb7d3a7
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions odilia/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ pub fn init(config: &ApplicationConfig) -> eyre::Result<()> {
.with_span_retrace(true)
.with_indent_lines(true)
.with_ansi(false)
.with_wraparound(4);
.with_wraparound(4)
.with_timer(Uptime::default());
//this requires boxing because the types returned by this match block would be incompatible otherwise, since we return different layers, or modifications to a layer depending on what we get from the configuration. It is possible to do it otherwise, hopefully, but for now this would do
let final_layer = match &config.log.logger {
LoggingKind::File(path) => {
Expand All @@ -43,23 +44,7 @@ pub fn init(config: &ApplicationConfig) -> eyre::Result<()> {
tracing_subscriber::Registry::default()
.with(env_filter)
.with(ErrorLayer::default())
.with(HierarchicalLayer::new(4)
.with_bracketed_fields(true)
.with_targets(true)
.with_deferred_spans(true)
.with_span_retrace(true)
.with_timer(Uptime::default())
.with_indent_lines(true));
//console_subscriber::ConsoleLayer::builder()
// // set how long the console will retain data from completed tasks
// .retention(Duration::from_secs(60))
// // set the address the server is bound to
// .server_addr(([127, 0, 0, 1], 5555))
// // ... other configurations ...
// .init();
tracing::subscriber::set_global_default(subscriber)
.wrap_err("unable to init default logging layer")?;
//LogTracer appears to cause a deadlock after some time... cannot quite figure out why
//LogTracer::init().wrap_err("unable to init tracing log layer")?;
.with(final_layer)
.init();
Ok(())
}

0 comments on commit cb7d3a7

Please sign in to comment.