1
Fork 0

filtered out some log bloat

This commit is contained in:
Andy Killorin 2023-12-25 13:34:34 -06:00
parent 95fcabc40e
commit 1b60bd74d7
Signed by: ank
GPG key ID: B6241CA3B552BCA4
6 changed files with 26 additions and 8 deletions

View file

@ -39,7 +39,7 @@ tower-layer = "0.3.2"
tracing = "0.1"
typetag = "0.2.14"
ucnlnav = { git = "https://github.com/ucnl/UCNLNav.git", version = "0.1.0" }
tracing-subscriber = "0.3"
tracing-subscriber = { version = "0.3", features = ["registry"] }
console-subscriber = "0.1.5"
opentelemetry = "0.17.0"
tracing-opentelemetry = "0.17.2"

View file

@ -9,7 +9,7 @@ use crate::{turtle::TurtleCommand, paths::{self, TRANSPARENT}};
pub type WorldReadLock = OwnedRwLockReadGuard<RTree<Block>>;
#[derive(Clone, Debug)]
#[derive(Clone)]
pub struct World {
state: Arc<RwLock<RTree<Block>>>, // interior mutability to get around the
// questionable architecture of this project

View file

@ -9,7 +9,7 @@ use typetag::serde;
use crate::{blocks::{Vec3, Position, Direction}, turtle::{TurtleCommander, TurtleCommand, TurtleCommandResponse, InventorySlot}, tasks::{Task, TaskState}, depot::Depots, mine::fill, paths::TRANSPARENT};
#[tracing::instrument]
#[tracing::instrument(skip(turtle))]
pub async fn fell_tree(turtle: TurtleCommander, bottom: Vec3) -> Option<()> {
let mut log = bottom;
loop {

View file

@ -12,7 +12,7 @@ use blocks::{World, Position, };
use depot::Depots;
use opentelemetry::global;
use tower_http::trace::TraceLayer;
use tracing::{info, span};
use tracing::{info, span, Level};
use rstar::RTree;
use names::Name;
@ -20,7 +20,7 @@ use tasks::Scheduler;
use tokio::{sync::{
RwLock, mpsc, OnceCell, Mutex, watch
}, fs, time::Instant, runtime::Runtime};
use tracing_subscriber::{fmt::format::FmtSpan, layer::SubscriberExt, util::SubscriberInitExt};
use tracing_subscriber::{fmt::format::FmtSpan, layer::{SubscriberExt, Filter}, util::SubscriberInitExt, filter, Layer};
use turtle::{Turtle, TurtleCommander};
use serde::{Deserialize, Serialize};
use indoc::formatdoc;
@ -63,11 +63,18 @@ async fn main() -> Result<(), Error> {
let opentelemetry = tracing_opentelemetry::layer().with_tracer(tracer);
let filter = filter::Targets::new()
.with_default(Level::INFO)
.with_target("server::tasks", Level::TRACE)
.with_target("server::turtle", Level::ERROR)
.with_target("server::turtle_api", Level::INFO)
.with_target("server::fell", Level::INFO);
let subscriber = tracing_subscriber::fmt::layer()
.compact()
.with_file(false)
.with_target(true)
.with_span_events(FmtSpan::ENTER);
.with_filter(filter);
tracing_subscriber::registry()
.with(opentelemetry)

View file

@ -6,6 +6,7 @@ use pathfinding::prelude::astar;
const LOOKUP_LIMIT: usize = 10_000_000;
#[tracing::instrument(skip(world))]
pub async fn route_facing(from: Position, to: Vec3, world: &World) -> Option<Vec<Position>> {
let facing = |p: &Position| {
let ahead = p.dir.unit() + p.pos;
@ -16,6 +17,7 @@ pub async fn route_facing(from: Position, to: Vec3, world: &World) -> Option<Vec
route_to(from, to, facing, world).await
}
#[tracing::instrument(skip(world))]
pub async fn route(from: Position, to: Position, world: &World) -> Option<Vec<Position>> {
trace!("routing from {from:?} to {to:?}");
// attempt at not crashing by looking infinitely into the abyss

View file

@ -23,6 +23,7 @@ use tokio::time::timeout;
use super::LiveState;
use core::fmt;
use std::sync::Arc;
use std::sync::atomic::AtomicUsize;
use std::time::Duration;
@ -139,7 +140,7 @@ impl Turtle {
}
}
#[derive(Clone, Debug)]
#[derive(Clone)]
pub struct TurtleCommander {
sender: Arc<Sender>,
world: World,
@ -152,6 +153,14 @@ pub struct TurtleCommander {
name: Arc<OnceCell<Name>>,
}
impl fmt::Debug for TurtleCommander {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Turtle {} ", self.name().to_str())?;
write!(f, "fuel: {} ", self.fuel())?;
write!(f, "fuel_limit: {} ", self.fuel_limit())
}
}
impl TurtleCommander {
pub async fn new(turtle: Name, state: &LiveState) -> Option<TurtleCommander> {
let turtle = state.turtles.get(turtle.to_num() as usize)?.clone();
@ -212,7 +221,7 @@ impl TurtleCommander {
self.world.clone()
}
#[tracing::instrument]
#[tracing::instrument(skip(self))]
pub async fn dock(&self) -> usize {
let mut wait = 1;
loop {