Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/nexum-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ thiserror.workspace = true
# Newtype boilerplate (`Display`, `AsRef`, `From`) for identity wrappers.
derive_more.workspace = true
# `strum::IntoStaticStr`: the snake_case variant name is the tracing
# `source` field (`LogSource`) and the boot-refusal `error_kind` label.
# `channel` field (`LogChannel`) and the boot-refusal `error_kind` label.
strum.workspace = true
# Full-semver interface ids and their compatibility tracks.
semver.workspace = true
Expand Down
8 changes: 4 additions & 4 deletions crates/nexum-runtime/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! component builders, add-ons) through a type-state chain;
//! [`ReadyBuilder::launch`] opens the backends and hands off to
//! [`AssembledRuntime::launch`], which installs add-ons, builds the engine and
//! linker, boots the supervisor, opens the trigger sources, spawns the event
//! linker, boots the supervisor, opens the sources, spawns the event
//! loop, and returns a [`RuntimeHandle`]. [`RuntimeBuilder::runtime`] binds a
//! [`Runtime`] preset for the common case.

Expand Down Expand Up @@ -296,7 +296,7 @@ impl<T: RuntimeTypes> AssembledRuntime<T> {
};

let alive = supervisor.alive_count();
let plan = supervisor.trigger_plan();
let plan = supervisor.source_plan();
info!(
modules = supervisor.module_count(),
alive,
Expand Down Expand Up @@ -347,7 +347,7 @@ impl<T: RuntimeTypes> AssembledRuntime<T> {
{
let mut sources = SourceContext::new(
engine_cfg,
&plan.extension_kinds,
&plan.demanded_extension_kinds,
&executor,
&mut reconnect_tasks,
);
Expand Down Expand Up @@ -387,7 +387,7 @@ impl<T: RuntimeTypes> AssembledRuntime<T> {
);
let chain_log_streams = event_loop::open_chain_log_streams(
&components.chain,
plan.event_triggers,
plan.event_sources,
&executor,
&mut reconnect_tasks,
);
Expand Down
4 changes: 2 additions & 2 deletions crates/nexum-runtime/src/host/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,12 +395,12 @@ mod tests {
}

let sink = Sink::default();
let subscriber = tracing_subscriber::fmt()
let collector = tracing_subscriber::fmt()
.with_max_level(tracing::Level::DEBUG)
.with_ansi(false)
.with_writer(sink.clone())
.finish();
tracing::subscriber::with_default(subscriber, || {
tracing::subscriber::with_default(collector, || {
let _ = store_fault(
"mod-a",
"set",
Expand Down
2 changes: 1 addition & 1 deletion crates/nexum-runtime/src/host/extension.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Extension seam: what one extension contributes to the host (namespace,
//! capabilities, linker hook, trigger sources, and manifest-section install
//! capabilities, linker hook, sources, and manifest-section install
//! predicates).

use std::collections::BTreeSet;
Expand Down
4 changes: 2 additions & 2 deletions crates/nexum-runtime/src/host/impls/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use tracing_core::Level;

use crate::bindings::nexum;
use crate::host::component::RuntimeTypes;
use crate::host::logs::{LogRecord, LogSource};
use crate::host::logs::{LogChannel, LogRecord};
use crate::host::state::HostState;

impl<T: RuntimeTypes> nexum::host::logging::Host for HostState<T> {
Expand All @@ -22,7 +22,7 @@ impl<T: RuntimeTypes> nexum::host::logging::Host for HostState<T> {
};
self.log_router.record(LogRecord::now(
self.run.clone(),
LogSource::HostInterface,
LogChannel::HostInterface,
level,
message,
));
Expand Down
36 changes: 18 additions & 18 deletions crates/nexum-runtime/src/host/logs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! event and the retention store. [`LogPipeline`] is the shared handle,
//! carrying the write side and the store's read side.
//!
//! One guest panic yields three records distinguished by [`LogSource`]
//! One guest panic yields three records distinguished by [`LogChannel`]
//! (stderr, host logging call, supervisor death), redundancy covering
//! channels that survive different failure modes.

Expand Down Expand Up @@ -47,11 +47,11 @@ impl RunId {
}

/// Which capture point produced a record; the snake_case name is the tracing
/// `source` field.
/// `channel` field.
#[derive(Debug, Clone, Copy, PartialEq, Eq, IntoStaticStr)]
#[strum(serialize_all = "snake_case")]
#[non_exhaustive]
pub enum LogSource {
pub enum LogChannel {
/// The `nexum:host/logging` glue: an explicit guest `log` call.
HostInterface,
/// A line captured from the guest's stdout pipe.
Expand All @@ -70,7 +70,7 @@ pub struct LogRecord {
/// Wall-clock capture time.
pub ts: SystemTime,
/// Capture point of origin.
pub source: LogSource,
pub channel: LogChannel,
/// Line severity.
pub level: Level,
/// The line text.
Expand All @@ -79,11 +79,11 @@ pub struct LogRecord {

impl LogRecord {
/// Record stamped at the current instant.
pub fn now(run: RunId, source: LogSource, level: Level, message: String) -> Self {
pub fn now(run: RunId, channel: LogChannel, level: Level, message: String) -> Self {
Self {
run,
ts: SystemTime::now(),
source,
channel,
level,
message,
}
Expand Down Expand Up @@ -133,18 +133,18 @@ impl LogRouter {
fn emit_tracing(record: &LogRecord) {
let module = record.run.module.as_str();
let run = record.run.seq;
let source: &'static str = record.source.into();
let channel: &'static str = record.channel.into();
let message = record.message.as_str();
if record.level == Level::TRACE {
tracing::trace!(module, run, source, "{message}");
tracing::trace!(module, run, channel, "{message}");
} else if record.level == Level::DEBUG {
tracing::debug!(module, run, source, "{message}");
tracing::debug!(module, run, channel, "{message}");
} else if record.level == Level::INFO {
tracing::info!(module, run, source, "{message}");
tracing::info!(module, run, channel, "{message}");
} else if record.level == Level::WARN {
tracing::warn!(module, run, source, "{message}");
tracing::warn!(module, run, channel, "{message}");
} else {
tracing::error!(module, run, source, "{message}");
tracing::error!(module, run, channel, "{message}");
}
}

Expand Down Expand Up @@ -225,14 +225,14 @@ mod tests {
let router = LogRouter::new(store.clone());
router.record(LogRecord::now(
RunId::new(test_module_id(), 0),
LogSource::HostInterface,
LogChannel::HostInterface,
Level::INFO,
"hello".to_owned(),
));
let appended = store.appended.lock().unwrap();
assert_eq!(appended.len(), 1, "retention consumer saw the record");
assert_eq!(appended[0].message, "hello");
assert_eq!(appended[0].source, LogSource::HostInterface);
assert_eq!(appended[0].channel, LogChannel::HostInterface);
}

#[test]
Expand All @@ -245,7 +245,7 @@ mod tests {
let run = RunId::new(test_module_id(), 0);
pipeline.router().record(LogRecord::now(
run.clone(),
LogSource::Stdout,
LogChannel::Stdout,
Level::INFO,
"line".to_owned(),
));
Expand All @@ -257,10 +257,10 @@ mod tests {
}

#[test]
fn source_names_are_snake_case_for_the_tracing_field() {
let s: &'static str = LogSource::HostInterface.into();
fn channel_names_are_snake_case_for_the_tracing_field() {
let s: &'static str = LogChannel::HostInterface.into();
assert_eq!(s, "host_interface");
let s: &'static str = LogSource::Panic.into();
let s: &'static str = LogChannel::Panic.into();
assert_eq!(s, "panic");
}
}
Loading
Loading