fix: default log level is info

When RUST_LOG isn't set, the default log level is INFO rather than
ERROR.

Closes kemitix/git-next#104
This commit is contained in:
Paul Campbell 2024-07-05 07:23:40 +01:00
parent 2483e85196
commit 694135a10b

View file

@ -4,8 +4,7 @@ use git_next_file_watcher_actor::{FileUpdated, FileWatcher};
use git_next_server_actor::Server; use git_next_server_actor::Server;
use kxio::{fs::FileSystem, network::Network}; use kxio::{fs::FileSystem, network::Network};
use std::path::PathBuf; use std::path::PathBuf;
use tracing::{error, info}; use tracing::{error, info, level_filters::LevelFilter};
use tracing_subscriber::EnvFilter;
pub use git_next_server_actor::{repository_factory, RepositoryFactory}; pub use git_next_server_actor::{repository_factory, RepositoryFactory};
@ -69,13 +68,17 @@ pub fn start(
pub fn init_logging() { pub fn init_logging() {
use tracing_subscriber::prelude::*; use tracing_subscriber::prelude::*;
use tracing_subscriber::EnvFilter;
let subscriber = tracing_subscriber::fmt::layer() let subscriber = tracing_subscriber::fmt::layer()
// NOTE: set RUSTLOG in ${root}/.cargo/config
.with_target(false) .with_target(false)
.with_file(true) .with_file(true)
.with_line_number(true) .with_line_number(true)
.with_filter(EnvFilter::from_default_env()); .with_filter(
EnvFilter::builder()
.with_default_directive(LevelFilter::INFO.into())
.from_env_lossy(),
);
tracing_subscriber::registry() tracing_subscriber::registry()
.with(console_subscriber::ConsoleLayer::builder().spawn()) .with(console_subscriber::ConsoleLayer::builder().spawn())
.with(subscriber) .with(subscriber)