\ No newline at end of file
diff --git a/cu29/prelude/index.html b/cu29/prelude/index.html
index b8e610ed4..f88a65ca9 100644
--- a/cu29/prelude/index.html
+++ b/cu29/prelude/index.html
@@ -36,7 +36,7 @@
They form a linked list of sections.
The entry type is used to identify the type of data in the section.
The time of validity of a message can be more than one time but can be a time range of Tovs.
-For example a sub scan for a lidar, a set of images etc… can have a range of validity.
A Src Task is a task that only produces messages. For example drivers for sensors are Src Tasks.
+For example a sub scan for a lidar, a set of images etc… can have a range of validity.
A Src Task is a task that only produces messages. For example drivers for sensors are Src Tasks.
They are in push mode from the runtime.
To set the frequency of the pulls and align them to any hw, see the runtime configuration.
Note: A source has the privilege to have a clock passed to it vs a frozen clock.
The internal state of a task needs to be serializable
diff --git a/cu29/prelude/sidebar-items.js b/cu29/prelude/sidebar-items.js
index dfde0a7d0..a319fab73 100644
--- a/cu29/prelude/sidebar-items.js
+++ b/cu29/prelude/sidebar-items.js
@@ -1 +1 @@
-window.SIDEBAR_ITEMS = {"attr":["copper_runtime"],"constant":["ANONYMOUS","MAX_LOG_PARAMS_ON_STACK"],"enum":["AllocatedSection","CopperListState","CuExecutionUnit","CuHandleInner","CuTaskCallbackState","CuTaskState","CuTaskType","Decision","SimOverride","Tov","UnifiedLogType","UnifiedLogger","Value"],"fn":["compute_runtime_plan","default_log_index_dir","find_task_type_for_id","format_logline","log","log_debug_mode","read_configuration","read_configuration_str","read_interned_strings","rebuild_logline","stream_write","to_value"],"macro":["debug","gen_cumsgs","input_msg","output_msg"],"mod":["config","copperlist","curuntime","cutask","monitoring","payload","pool","simulation"],"static":["GLOBAL"],"struct":["AlignedBuffer","Cnx","ComponentConfig","CopperContext","CopperLiskMask","CopperList","CountingAllocator","CuArray","CuCompactString","CuConfig","CuDuration","CuDurationStatistics","CuError","CuExecutionLoop","CuExecutionStep","CuHandle","CuHostMemoryPool","CuListsManager","CuLogEntry","CuMsg","CuMsgMetadata","CuRuntime","CuSimSinkTask","CuSimSrcTask","CuTimeRange","Instant","LiveStatistics","LoggerRuntime","LoggingConfig","MonitorConfig","NoMonitor","Node","NullLog","OptionCuTime","OwningIoWriter","PartialCuTimeRange","RobotClock","RobotClockMock","ScopedAllocCounter","SectionHandle","SectionHeader","SimpleFileWriter","UnifiedLoggerBuilder","UnifiedLoggerIOReader","UnifiedLoggerRead","UnifiedLoggerWrite"],"trait":["ArrayLike","ClockProvider","CopperListTuple","CuMonitor","CuMsgPack","CuMsgPayload","CuPool","CuSinkTask","CuSrcTask","CuTask","DeviceCuPool","ElementType","Freezable","WriteStream"],"type":["AscIter","AscIterMut","CuResult","CuTime","Iter","IterMut","NodeId"]};
\ No newline at end of file
+window.SIDEBAR_ITEMS = {"attr":["copper_runtime"],"constant":["ANONYMOUS","MAX_LOG_PARAMS_ON_STACK"],"enum":["AllocatedSection","CopperListState","CuExecutionUnit","CuHandleInner","CuTaskCallbackState","CuTaskState","CuTaskType","Decision","SimOverride","Tov","UnifiedLogType","UnifiedLogger","Value"],"fn":["compute_runtime_plan","default_log_index_dir","find_task_type_for_id","format_logline","log","log_debug_mode","read_configuration","read_configuration_str","read_interned_strings","rebuild_logline","stream_write","to_value"],"macro":["debug","gen_cumsgs","input_msg","output_msg"],"mod":["config","copperlist","curuntime","cutask","monitoring","payload","pool","simulation"],"static":["EXTRA_TEXT_LOGGER","GLOBAL"],"struct":["AlignedBuffer","Cnx","ComponentConfig","CopperContext","CopperLiskMask","CopperList","CountingAllocator","CuArray","CuCompactString","CuConfig","CuDuration","CuDurationStatistics","CuError","CuExecutionLoop","CuExecutionStep","CuHandle","CuHostMemoryPool","CuListsManager","CuLogEntry","CuMsg","CuMsgMetadata","CuRuntime","CuSimSinkTask","CuSimSrcTask","CuTimeRange","Instant","LiveStatistics","LoggerRuntime","LoggingConfig","MonitorConfig","NoMonitor","Node","NullLog","OptionCuTime","OwningIoWriter","PartialCuTimeRange","RobotClock","RobotClockMock","ScopedAllocCounter","SectionHandle","SectionHeader","SimpleFileWriter","UnifiedLoggerBuilder","UnifiedLoggerIOReader","UnifiedLoggerRead","UnifiedLoggerWrite"],"trait":["ArrayLike","ClockProvider","CopperListTuple","CuMonitor","CuMsgPack","CuMsgPayload","CuPool","CuSinkTask","CuSrcTask","CuTask","DeviceCuPool","ElementType","Freezable","WriteStream"],"type":["AscIter","AscIterMut","CuResult","CuTime","Iter","IterMut","NodeId"]};
\ No newline at end of file
diff --git a/cu29/prelude/static.EXTRA_TEXT_LOGGER.html b/cu29/prelude/static.EXTRA_TEXT_LOGGER.html
new file mode 100644
index 000000000..416858f94
--- /dev/null
+++ b/cu29/prelude/static.EXTRA_TEXT_LOGGER.html
@@ -0,0 +1 @@
+EXTRA_TEXT_LOGGER in cu29::prelude - Rust
\ No newline at end of file
diff --git a/cu29/prelude/struct.LoggerRuntime.html b/cu29/prelude/struct.LoggerRuntime.html
index 6e2677f89..21febb194 100644
--- a/cu29/prelude/struct.LoggerRuntime.html
+++ b/cu29/prelude/struct.LoggerRuntime.html
@@ -4,7 +4,7 @@
destination: impl WriteStream<CuLogEntry> + 'static,
extra_text_logger: Option<impl Log + 'static>,
) -> LoggerRuntime
destination is the binary stream in which we will log the structured log.
-extra_text_logger is the logger that will log the text logs in real time. This is slow and only for debug builds.
+extra_text_logger is the logger that will log the text logs in real time. This is slow and only for debug builds.
where
diff --git a/cu29_log_runtime/all.html b/cu29_log_runtime/all.html
index 6a43c8c71..68c185b4a 100644
--- a/cu29_log_runtime/all.html
+++ b/cu29_log_runtime/all.html
@@ -1 +1 @@
-List of all items in this crate
\ No newline at end of file
diff --git a/cu29_log_runtime/fn.log.html b/cu29_log_runtime/fn.log.html
index a920df976..6a8f4faee 100644
--- a/cu29_log_runtime/fn.log.html
+++ b/cu29_log_runtime/fn.log.html
@@ -1,3 +1,3 @@
-log in cu29_log_runtime - Rust
Function called from generated code to log data.
It moves entry by design, it will be absorbed in the queue.
\ No newline at end of file
diff --git a/cu29_log_runtime/fn.log_debug_mode.html b/cu29_log_runtime/fn.log_debug_mode.html
index 943b1df40..33a871c48 100644
--- a/cu29_log_runtime/fn.log_debug_mode.html
+++ b/cu29_log_runtime/fn.log_debug_mode.html
@@ -1,4 +1,4 @@
-log_debug_mode in cu29_log_runtime - Rust
This version of log is only compiled in debug mode
This allows a normal logging framework to be bridged.
\ No newline at end of file
diff --git a/cu29_log_runtime/sidebar-items.js b/cu29_log_runtime/sidebar-items.js
index 3f50cfed7..fd1af6a81 100644
--- a/cu29_log_runtime/sidebar-items.js
+++ b/cu29_log_runtime/sidebar-items.js
@@ -1 +1 @@
-window.SIDEBAR_ITEMS = {"fn":["log","log_debug_mode"],"struct":["LoggerRuntime","NullLog","OwningIoWriter","SimpleFileWriter"]};
\ No newline at end of file
+window.SIDEBAR_ITEMS = {"fn":["log","log_debug_mode"],"static":["EXTRA_TEXT_LOGGER"],"struct":["LoggerRuntime","NullLog","OwningIoWriter","SimpleFileWriter"]};
\ No newline at end of file
diff --git a/cu29_log_runtime/static.EXTRA_TEXT_LOGGER.html b/cu29_log_runtime/static.EXTRA_TEXT_LOGGER.html
new file mode 100644
index 000000000..c62322a0e
--- /dev/null
+++ b/cu29_log_runtime/static.EXTRA_TEXT_LOGGER.html
@@ -0,0 +1 @@
+EXTRA_TEXT_LOGGER in cu29_log_runtime - Rust
\ No newline at end of file
diff --git a/cu29_log_runtime/struct.LoggerRuntime.html b/cu29_log_runtime/struct.LoggerRuntime.html
index 09e7b2d72..cc2dd6ee7 100644
--- a/cu29_log_runtime/struct.LoggerRuntime.html
+++ b/cu29_log_runtime/struct.LoggerRuntime.html
@@ -1,11 +1,11 @@
-LoggerRuntime in cu29_log_runtime - Rust
destination is the binary stream in which we will log the structured log.
-extra_text_logger is the logger that will log the text logs in real time. This is slow and only for debug builds.
use bincode::config::Configuration;
use bincode::enc::write::Writer;
use bincode::enc::Encode;
use bincode::enc::{Encoder, EncoderImpl};
@@ -291,11 +288,7 @@
use log::Log;
#[cfg(debug_assertions)]
-use cu29_log::format_logline;
-#[cfg(debug_assertions)]
-use log::Record;
-#[cfg(debug_assertions)]
-use std::collections::HashMap;
+use {cu29_log::format_logline, std::collections::HashMap, std::sync::RwLock};
use std::fmt::{Debug, Formatter};
use std::fs::File;
@@ -318,9 +311,9 @@
static WRITER: OnceLock<WriterPair> = OnceLock::new();
#[cfg(debug_assertions)]
-static EXTRA_TEXT_LOGGER: OnceLock<Option<Box<dyn Log>>> = OnceLock::new();
+pub static EXTRA_TEXT_LOGGER: RwLock<Option<Box<dyn Log + 'static>>> = RwLock::new(None);
-pub struct NullLog {}
+pub struct NullLog;
impl Log for NullLog {
fn enabled(&self, _metadata: &log::Metadata) -> bool {
false
@@ -335,7 +328,7 @@
impl LoggerRuntime {
/// destination is the binary stream in which we will log the structured log.
- /// extra_text_logger is the logger that will log the text logs in real time. This is slow and only for debug builds.
+ /// `extra_text_logger` is the logger that will log the text logs in real time. This is slow and only for debug builds.
pub fn init(
clock: RobotClock,
destination: impl WriteStream<CuLogEntry> + 'static,
@@ -354,8 +347,9 @@
.unwrap();
}
#[cfg(debug_assertions)]
- let _ =
- EXTRA_TEXT_LOGGER.set(extra_text_logger.map(|logger| Box::new(logger) as Box<dyn Log>));
+ if let Some(logger) = extra_text_logger {
+ *EXTRA_TEXT_LOGGER.write().unwrap() = Some(Box::new(logger) as Box<dyn Log>);
+ }
runtime
}
@@ -420,11 +414,11 @@
) -> CuResult<()> {
log(entry)?;
- let guarded_logger = EXTRA_TEXT_LOGGER.get();
+ let guarded_logger = EXTRA_TEXT_LOGGER.read().unwrap();
if guarded_logger.is_none() {
return Ok(());
}
- if let Some(logger) = guarded_logger.unwrap() {
+ if let Some(logger) = guarded_logger.as_ref() {
let fstr = format_str.to_string();
// transform the slice into a hashmap
let params: Vec<String> = entry.params.iter().map(|v| v.to_string()).collect();
@@ -440,7 +434,7 @@
.collect();
let logline = format_logline(entry.time, &fstr, params.as_slice(), &named_params)?;
logger.log(
- &Record::builder()
+ &log::Record::builder()
.args(format_args!("{logline}"))
.level(log::Level::Info)
.target("cu29_log")