Skip to content

Commit

Permalink
finalize tracing logger
Browse files Browse the repository at this point in the history
  • Loading branch information
nothendev committed Oct 1, 2023
1 parent fadab48 commit 86cae2d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cli/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{borrow::Cow, num::ParseIntError, ops::Range, str::FromStr};
use std::{borrow::Cow, num::ParseIntError, ops::Range};

use oxcr_protocol::{
aott,
Expand Down
18 changes: 10 additions & 8 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use oxcr_protocol::{
aott::{self, prelude::Parser},
bytes::Bytes,
error::Error,
logging::CraftLayer,
miette::{self, bail, IntoDiagnostic, Report},
model::{
packets::{play::LoginPlay, Packet, PacketContext, SerializedPacket},
Expand All @@ -12,18 +13,19 @@ use oxcr_protocol::{
ser::{BytesSource, Deserialize, Serialize, WithSource},
tracing::debug,
};
use tracing_subscriber::{util::SubscriberInitExt, EnvFilter};
use tracing_subscriber::{
prelude::__tracing_subscriber_SubscriberExt, util::SubscriberInitExt, EnvFilter,
};

use crate::cli::{ByteInput, Cli, CliCommand};

mod cli;
mod error;

fn run(_path: String, args: &str) -> Result<(), Report> {
let tracing_set_default_level = tracing_subscriber::fmt()
.pretty()
.with_env_filter(EnvFilter::from_env("OXCR_LOG"))
.finish()
let tracing_set_default_level = tracing_subscriber::registry()
.with(EnvFilter::from_env("OXCR_LOG"))
.with(CraftLayer)
.set_default();

let cli = cli::yay
Expand All @@ -32,9 +34,9 @@ fn run(_path: String, args: &str) -> Result<(), Report> {

drop(tracing_set_default_level);

let _tracing_set_real_level = tracing_subscriber::fmt()
.with_env_filter(cli.level.to_string())
.pretty()
let _tracing_set_real_level = tracing_subscriber::registry()
.with(EnvFilter::new(cli.level.to_string()))
.with(CraftLayer)
.set_default();

debug!("{:?}", cli);
Expand Down
1 change: 1 addition & 0 deletions protocol/src/logging.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(unstable_name_collisions)]
use std::collections::HashMap;

use itertools::Itertools;
Expand Down

0 comments on commit 86cae2d

Please sign in to comment.