add logging to file

This commit is contained in:
Tao Tien 2026-02-24 14:17:10 -08:00
parent 550ae73287
commit 093af571d2
3 changed files with 16 additions and 7 deletions

4
.gitignore vendored
View file

@ -1,3 +1,5 @@
*.log
target
# Devenv
@ -10,5 +12,3 @@ devenv.local.yaml
# pre-commit
.pre-commit-config.yaml
mprocs.log

View file

@ -1,7 +1,14 @@
use std::fs::File;
use bevy::{log::LogPlugin, prelude::*};
use clap::{Parser, Subcommand};
use tracing::Level;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
use tracing_subscriber::{
Layer,
fmt::{self, layer},
layer::SubscriberExt,
util::SubscriberInitExt,
};
// mod gui;
mod tui;
@ -33,6 +40,7 @@ fn main() {
Mode::RunTui => {
tracing_subscriber::registry()
.with(tui_logger::TuiTracingSubscriberLayer)
.with(fmt::layer().with_writer(File::create("jong.log").unwrap()))
.init();
tui_logger::init_logger(tui_logger::LevelFilter::Trace).unwrap();
tui_logger::set_env_filter_from_string(FILTERSTRING);

View file

@ -180,15 +180,16 @@ fn spawn_main_player(
fn spawn_other_player(stdb: &SpacetimeDB, commands: &mut Commands, player: &jong_db::Player) {
let id = PlayerOrBot::Player { id: player.id };
let hand_view = stdb
if let Some(hand_view) = stdb
.db()
.view_closed_hands()
.iter()
.find(|v| PlayerOrBot::from(&v.player) == id)
.unwrap();
{
let hand_ent = commands.spawn((Hand, Closed(hand_view.hand_length))).id();
commands.spawn(Player { id }).add_child(hand_ent);
}
}
fn on_player_insert_update(
stdb: SpacetimeDB,