Skip to content

Commit

Permalink
fix(log): correctly write to the client pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
vyfor committed Dec 13, 2024
1 parent bebea1f commit 710b83e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/messages/events/server/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ pub struct LogEvent {

use std::collections::HashMap;

use crate::ipc::pipe::PipeServerImpl;
use crate::messages::events::event::{EventContext, OnEvent};
use crate::protocol::msgpack::{Serialize, ValueRef};
use crate::protocol::msgpack::{MsgPack, Serialize, ValueRef};
use crate::util::logger::LogLevel;

impl OnEvent for LogEvent {
fn on_event(self, ctx: &mut EventContext) -> crate::Result<()> {
ctx.cord
.logger
.log(self.level, self.message.into(), ctx.client_id);
let data = MsgPack::serialize(&self)?;
match ctx.client_id {
0 => ctx.cord.pipe.broadcast(&data)?,
_ => ctx.cord.pipe.write_to(ctx.client_id, &data)?,
}

Ok(())
}
Expand Down

0 comments on commit 710b83e

Please sign in to comment.