add fern logging
Some checks failed
Rust/sat-rs/pipeline/head There was a failure building this commit
Some checks failed
Rust/sat-rs/pipeline/head There was a failure building this commit
This commit is contained in:
parent
d0005cdd63
commit
9d711d2b73
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
|||||||
target/
|
target/
|
||||||
|
|
||||||
/Cargo.lock
|
/Cargo.lock
|
||||||
|
output.log
|
||||||
|
|
||||||
/.idea/*
|
/.idea/*
|
||||||
!/.idea/runConfigurations
|
!/.idea/runConfigurations
|
||||||
|
@ -10,6 +10,8 @@ serde = { version = "1", features = ["derive"] }
|
|||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
|
fern = "0.5"
|
||||||
|
humantime = "2"
|
||||||
|
|
||||||
[dependencies.asynchronix]
|
[dependencies.asynchronix]
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
use asynchronix::time::MonotonicTime;
|
use asynchronix::time::MonotonicTime;
|
||||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||||
|
|
||||||
|
pub const SIM_CTRL_UDP_PORT: u16 = 7303;
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum SimTarget {
|
pub enum SimTarget {
|
||||||
SimCtrl,
|
SimCtrl,
|
||||||
|
@ -3,7 +3,7 @@ use asynchronix::simulation::{Mailbox, SimInit};
|
|||||||
use asynchronix::time::{MonotonicTime, SystemClock};
|
use asynchronix::time::{MonotonicTime, SystemClock};
|
||||||
use controller::SimController;
|
use controller::SimController;
|
||||||
use eps::PcduModel;
|
use eps::PcduModel;
|
||||||
use satrs_minisim::{SimReply, SimRequest};
|
use satrs_minisim::{SimReply, SimRequest, SIM_CTRL_UDP_PORT};
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::{Duration, SystemTime};
|
use std::time::{Duration, SystemTime};
|
||||||
@ -83,14 +83,37 @@ fn main() {
|
|||||||
let t0 = MonotonicTime::EPOCH;
|
let t0 = MonotonicTime::EPOCH;
|
||||||
let mut sim_ctrl =
|
let mut sim_ctrl =
|
||||||
create_sim_controller(ThreadingModel::Default, t0, reply_sender, request_receiver);
|
create_sim_controller(ThreadingModel::Default, t0, reply_sender, request_receiver);
|
||||||
|
// Configure logger at runtime
|
||||||
|
fern::Dispatch::new()
|
||||||
|
// Perform allocation-free log formatting
|
||||||
|
.format(|out, message, record| {
|
||||||
|
out.finish(format_args!(
|
||||||
|
"[{} {} {}] {}",
|
||||||
|
humantime::format_rfc3339(std::time::SystemTime::now()),
|
||||||
|
record.level(),
|
||||||
|
record.target(),
|
||||||
|
message
|
||||||
|
))
|
||||||
|
})
|
||||||
|
// Add blanket level filter -
|
||||||
|
.level(log::LevelFilter::Debug)
|
||||||
|
// - and per-module overrides
|
||||||
|
// Output to stdout, files, and other Dispatch configurations
|
||||||
|
.chain(std::io::stdout())
|
||||||
|
.chain(fern::log_file("output.log").expect("could not open log output file"))
|
||||||
|
// Apply globally
|
||||||
|
.apply().expect("could not apply logger configuration");
|
||||||
|
|
||||||
|
log::info!("starting simulation thread");
|
||||||
// This thread schedules the simulator.
|
// This thread schedules the simulator.
|
||||||
let sim_thread = thread::spawn(move || {
|
let sim_thread = thread::spawn(move || {
|
||||||
sim_ctrl.run(t0, 1);
|
sim_ctrl.run(t0, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut udp_server = SimUdpServer::new(0, request_sender, reply_receiver, 200, None)
|
let mut udp_server =
|
||||||
.expect("could not create UDP request server");
|
SimUdpServer::new(SIM_CTRL_UDP_PORT, request_sender, reply_receiver, 200, None)
|
||||||
|
.expect("could not create UDP request server");
|
||||||
|
log::info!("starting UDP server on port {}", SIM_CTRL_UDP_PORT);
|
||||||
// This thread manages the simulator UDP server.
|
// This thread manages the simulator UDP server.
|
||||||
let udp_tc_thread = thread::spawn(move || {
|
let udp_tc_thread = thread::spawn(move || {
|
||||||
udp_server.run();
|
udp_server.run();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user