Skip to content

Commit

Permalink
studio: Update log levels to reduce spam
Browse files Browse the repository at this point in the history
  • Loading branch information
YaLTeR committed Jul 23, 2023
1 parent 8d46962 commit f886ea0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/modules/tas_studio/hltas_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn write_first_version(path: &Path, script: &HLTAS) -> eyre::Result<()> {
stem.push("-backup.hltas");
let backup_name = path.with_file_name(stem);

debug!(
trace!(
"{} already exists, renaming it to {}",
path.to_string_lossy(),
backup_name.to_string_lossy(),
Expand Down Expand Up @@ -164,7 +164,7 @@ impl Bridge {
return None;
}

info!("reading updated bridged .hltas");
trace!("reading updated bridged .hltas");

let _span = info_span!("bridge reading script").entered();

Expand Down
21 changes: 12 additions & 9 deletions src/modules/tas_studio/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ fn server_thread(listener: TcpListener) {

let mut state = STATE.lock().unwrap();
if let Some(State::Server(Some(_))) = *state {
info!("continuing because already have a client");
trace!("continuing because already have a client");
continue;
}

Expand All @@ -139,7 +139,7 @@ fn server_thread(listener: TcpListener) {

let (server, name) = IpcOneShotServer::new().unwrap();

info!("Accepted remote client connection, replying with name: {name}");
debug!("Accepted remote client connection, replying with name: {name}");

if let Err(err) = stream.write_all(name.as_bytes()) {
error!("Error sending IPC server name to the remote client: {err:?}");
Expand Down Expand Up @@ -245,9 +245,10 @@ fn client_connection_thread() {

let (receiver, sender) = match connect_to_server(stream) {
Ok(x) => x,
Err(_err) => {
// The server will refuse connections if it doesn't need one. Don't spam the log.
// error!("error connecting to server: {err:?}");
Err(err) => {
// The server will refuse connections if it doesn't need one. Use trace!() and no
// backtrace (no :?) to not spam the log.
trace!("error connecting to server: {err}");
continue;
}
};
Expand All @@ -259,15 +260,17 @@ fn client_connection_thread() {
fn connect_to_server(
mut stream: TcpStream,
) -> eyre::Result<(IpcReceiver<PlayRequest>, IpcSender<AccurateFrame>)> {
debug!("reading IPC name from server");
// The first messages are trace!() because they will spam every second if we're trying to
// connect to a server which already has a game connected.
trace!("reading IPC name from server");

let mut name = String::new();
stream
.read_to_string(&mut name)
.context("error reading IPC name from server")?;
drop(stream);

debug!("connecting to server IPC");
trace!("connecting to server IPC");
let tx = IpcSender::connect(name).context("error connecting to the server IPC")?;

let (hltas_sender, request_receiver) =
Expand All @@ -280,11 +283,11 @@ fn connect_to_server(
let (workaround_sender, workaround_receiver) =
ipc_channel::ipc::channel().context("error creating workaround IPC channel")?;

debug!("sending senders to server");
trace!("sending senders to server");
tx.send((hltas_sender, workaround_sender))
.context("error sending IPC channels to server")?;

debug!("receiving sender from server");
trace!("receiving sender from server");
let response_sender = workaround_receiver
.recv()
.context("error receiving frames sender from server")?;
Expand Down
4 changes: 2 additions & 2 deletions src/modules/tas_studio/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ impl Watcher {
thread::sleep(Duration::from_millis(500));

if should_stop.load(Ordering::SeqCst) {
debug!("Exiting watcher thread for {}", path.to_string_lossy());
trace!("Exiting watcher thread for {}", path.to_string_lossy());
break;
}

if let Ok(mtime) = path.metadata().and_then(|meta| meta.modified()) {
if last_mtime != Some(mtime) {
has_changed.store(true, Ordering::SeqCst);
last_mtime = Some(mtime);
debug!("file changed: {}", path.to_string_lossy());
trace!("file changed: {}", path.to_string_lossy());
}
}
}
Expand Down

0 comments on commit f886ea0

Please sign in to comment.