Skip to content

Commit

Permalink
feat: adjust log output
Browse files Browse the repository at this point in the history
  • Loading branch information
pk5ls20 committed Feb 10, 2025
1 parent d3cab35 commit 731316b
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/multi_login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async fn main() {
.with(console_layer)
.with(
tracing_subscriber::fmt::layer()
.with_filter(tracing_subscriber::EnvFilter::new("debug")),
.with_filter(tracing_subscriber::EnvFilter::new("trace")),
)
.init();
tracing::info!("tokio-tracing initialized.");
Expand Down
11 changes: 7 additions & 4 deletions mania/src/core/business.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static LOGIC_MAP: Lazy<LogicHandlerMap> = Lazy::new(|| {
map.entry(tid)
.or_insert_with(Vec::new)
.push(item.event_handle_fn);
tracing::debug!(
tracing::trace!(
"Registered event handler {:?} for type: {:?}",
item.event_handle_fn,
tid
Expand All @@ -93,12 +93,12 @@ pub async fn dispatch_logic(
) -> &dyn ServerEvent {
let tid = event.as_any().type_id();
if let Some(fns) = LOGIC_MAP.get(&tid) {
tracing::debug!("[{}] Found {} handlers for {:?}.", flow, fns.len(), event);
tracing::trace!("[{}] Found {} handlers for {:?}.", flow, fns.len(), event);
for handle_fn in fns.iter() {
handle_fn(event, handle.to_owned(), flow).await;
}
} else {
tracing::debug!("[{}] No handler found for {:?}", flow, event);
tracing::trace!("[{}] No handler found for {:?}", flow, event);
}
event
}
Expand Down Expand Up @@ -153,6 +153,8 @@ impl Business {
continue;
}
};
tracing::debug!("Incoming packet: {}", packet.command());
tracing::trace!("Full: {:?}", packet);
let handle = self.handle.clone();
tokio::spawn(async move {
if let Err(e) = handle.dispatch_sso_packet(packet).await {
Expand Down Expand Up @@ -285,12 +287,13 @@ impl BusinessHandle {
}

async fn post_packet(&self, packet: SsoPacket) -> BusinessResult<()> {
tracing::debug!("Outgoing packet: {}", packet.command());
tracing::trace!("Full: {:?}", packet);
let packet = packet.build(&self.context);
Ok(self.sender.load().send(packet).await?)
}

async fn send_packet(&self, packet: SsoPacket) -> BusinessResult<CEParse> {
tracing::debug!("sending packet: {:?}", packet);
let sequence = packet.sequence();
let (tx, rx) = oneshot::channel::<BusinessResult<CEParse>>();
self.pending_requests.insert(sequence, tx);
Expand Down
2 changes: 1 addition & 1 deletion mania/src/core/business/messaging_logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async fn messaging_logic(
handle: Arc<BusinessHandle>,
flow: LogicFlow,
) -> &dyn ServerEvent {
tracing::debug!("[{}] Handling event: {:?}", flow, event);
tracing::trace!("[{}] Handling event: {:?}", flow, event);
match flow {
LogicFlow::InComing => messaging_logic_incoming(event, handle).await,
LogicFlow::OutGoing => messaging_logic_outgoing(event, handle).await,
Expand Down
1 change: 0 additions & 1 deletion mania/src/core/business/wt_logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ async fn messaging_logic(
handle: Arc<BusinessHandle>,
flow: LogicFlow,
) -> &dyn ServerEvent {
tracing::debug!("[{}] Handling event: {:?}", flow, event);
match flow {
LogicFlow::InComing => messaging_logic_incoming(event, handle).await,
LogicFlow::OutGoing => event,
Expand Down
5 changes: 0 additions & 5 deletions mania/src/core/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ static EVENT_MAP: Lazy<EventMap> = Lazy::new(|| {
pub async fn resolve_event(packet: SsoPacket, context: &Arc<Context>) -> CEParseResult {
// Lagrange.Core.Internal.Context.ServiceContext.ResolveEventByPacket
let payload = PacketReader::new(packet.payload()).section(|p| p.bytes());
tracing::debug!(
"receive SSO event: {}, payload: {:?}",
packet.command(),
hex::encode(&payload)
);
let Some(parse) = EVENT_MAP.get(packet.command()) else {
return Err(EventError::UnsupportedEvent(packet.command().to_string()));
};
Expand Down
3 changes: 1 addition & 2 deletions mania/src/core/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::sync::{Arc, Weak};

use byteorder::{BigEndian, ByteOrder};
use bytes::{Bytes, BytesMut};
use log::debug;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::tcp::{OwnedReadHalf, OwnedWriteHalf};
use tokio::sync::mpsc::{Receiver, Sender};
Expand Down Expand Up @@ -103,7 +102,7 @@ async fn recv_loop(mut stream: OwnedReadHalf, channel: Sender<Bytes>) -> Result<
buffer.resize(packet_length as usize, 0);
BigEndian::write_u32(&mut buffer, packet_length);
stream.read_exact(&mut buffer[4..]).await?;
debug!("Received packet (len= {:?})", buffer.len());
tracing::trace!("Received packet (len= {:?})", buffer.len());

if channel.send(buffer.split().freeze()).await.is_err() {
return Ok(()); // dropped
Expand Down
1 change: 0 additions & 1 deletion mania/src/core/tlv/t106.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ impl TlvSer for T106 {
}

fn serialize(&self, p: PacketBuilder) -> PacketBuilder {
tracing::warn!("T106: &self.temp = {}", hex::encode(&self.temp));
p.tlv(0x106, |p| p.bytes(&self.temp))
}
}
Expand Down

0 comments on commit 731316b

Please sign in to comment.