Skip to content

Commit 854b206

Browse files
committed
add logging framework
1 parent 9a59211 commit 854b206

21 files changed

+226
-44
lines changed

.cargo/config.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[env]
22
# If you placed InertialFlowCutter in another directory, you have to set an environment variable with the corresponding path.
33
# This variable has only to be set if you want to use a router.
4-
INERTIAL_FLOW_CUTTER_HOME_DIRECTORY= "../InertialFlowCutter"
4+
INERTIAL_FLOW_CUTTER_HOME_DIRECTORY="../InertialFlowCutter"
5+
RUST_Q_SIM_PERFORMANCE_TRACING_INTERVAL="900"

Cargo.lock

Lines changed: 127 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ prost = "0.11.5"
2525
bytes = "1.3.0"
2626
serial_test = "1.0.0"
2727
wait-timeout = "0.2.0"
28+
tracing = "0.1"
29+
tracing-subscriber = { version = "0.3.0", features = ["json", "fmt", "std", "registry"] }
30+
tracing-appender = "0.2"
31+
itertools = "0.10.5"
2832

2933
[build-dependencies]
3034
# generates types based on .proto files

src/bin/mpi_qsim.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
use clap::Parser;
2-
use log::info;
32
use mpi::traits::Communicator;
43
use rust_q_sim::simulation::config::Config;
54
use rust_q_sim::simulation::logging;
5+
use tracing::info;
66

77
fn main() {
88
let universe = mpi::initialize().unwrap();
99
let rank = universe.world().rank();
1010
let config = Config::parse();
11-
let _logger_handle = logging::init_logging(config.output_dir.as_ref(), Some(rank.to_string()));
11+
let _guards = logging::init_logging(config.output_dir.as_ref(), rank.to_string());
1212

1313
info!("{}", mpi::environment::library_version().unwrap());
1414

src/simulation/controller.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use crate::simulation::routing::router::Router;
1414
use crate::simulation::routing::travel_times_collecting_road_router::TravelTimesCollectingRoadRouter;
1515
use crate::simulation::routing::walk_leg_updater::{EuclideanWalkLegUpdater, WalkLegUpdater};
1616
use crate::simulation::simulation::Simulation;
17-
use log::info;
1817
use mpi::topology::SystemCommunicator;
1918
use mpi::traits::{Communicator, CommunicatorCollectives};
2019
use std::ffi::c_int;
@@ -23,6 +22,7 @@ use std::fs::remove_dir_all;
2322
use std::ops::Sub;
2423
use std::path::PathBuf;
2524
use std::time::Instant;
25+
use tracing::info;
2626

2727
pub fn run(world: SystemCommunicator, config: Config) {
2828
let rank = world.rank();

src/simulation/id_mapping.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use crate::simulation::io::matsim_id::MatsimId;
22
use crate::simulation::io::network::IONetwork;
33
use crate::simulation::io::population::{IOPlanElement, IOPopulation};
4-
use log::info;
54
use serde::{Deserialize, Serialize};
65
use std::collections::HashMap;
76
use std::sync::Arc;
7+
use tracing::info;
88

99
#[derive(Debug)]
1010
pub struct MatsimIdMappings {

src/simulation/io/network.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ use crate::simulation::io::matsim_id::MatsimId;
33
use crate::simulation::io::xml_reader;
44
use crate::simulation::network::network::Network;
55
use flate2::Compression;
6-
use log::info;
76
use quick_xml::se::to_writer;
87
use serde::{Deserialize, Serialize};
98
use std::fmt::Debug;
109
use std::fs;
1110
use std::fs::File;
1211
use std::io::{BufWriter, Write};
1312
use std::path::Path;
13+
use tracing::info;
1414

1515
#[derive(Debug, Deserialize, Serialize, PartialEq, Clone)]
1616
pub struct Attr {

src/simulation/io/population.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use log::info;
21
use serde::Deserialize;
2+
use tracing::info;
33

44
use crate::simulation::io::matsim_id::MatsimId;
55
use crate::simulation::io::xml_reader;

src/simulation/io/xml_events.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use crate::simulation::messaging::events::proto::event::Type;
22
use crate::simulation::messaging::events::proto::Event;
33
use crate::simulation::messaging::events::EventsSubscriber;
4-
use log::info;
54
use std::any::Any;
65
use std::fs::File;
76
use std::io::{BufWriter, Write};
87
use std::path::Path;
8+
use tracing::info;
99

1010
pub struct XmlEventsWriter {
1111
writer: BufWriter<File>,

src/simulation/io/xml_reader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use log::{debug, info};
21
use quick_xml::de::from_reader;
32
use serde::de::DeserializeOwned;
43
use std::fs;
54
use std::fs::File;
65
use std::io::BufReader;
6+
use tracing::{debug, info};
77

88
pub fn read<T>(file_path: &str) -> T
99
where

0 commit comments

Comments
 (0)