-
Notifications
You must be signed in to change notification settings - Fork 44
feat(logging): add configurable operational logging #413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rapids-bot
merged 26 commits into
NVIDIA:main
from
ericevans-nv:feat/persistent-relay-logging
Jul 16, 2026
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
6e70722
feat(cli): add persistent operational process logging
ericevans-nv d4a185e
Merge branch 'main' of github.com:NVIDIA/NeMo-Relay into feat/persist…
ericevans-nv 71cd417
chore: refresh Rust attributions for spdlog-rs deps
ericevans-nv d675d2f
Merge remote-tracking branch 'upstream/main' into feat/persistent-rel…
ericevans-nv 1e54b7e
Merge remote-tracking branch 'upstream/main' into feat/persistent-rel…
ericevans-nv ba2cdec
fix(cli): restore ffi header drift from merge hooks
ericevans-nv f424679
docs: remove operational logging section from feature PR
ericevans-nv c7a2167
refactor(logging): move operational logging into core logging module
ericevans-nv d949564
fix(logging): remove field redaction and bound file sink queue_capacity
ericevans-nv 60d8662
docs(logging): simplify max_queue_capacity constant comment
ericevans-nv 58893eb
fix(logging): harden file sink configuration
ericevans-nv 19d5c3e
Merge upstream/main into feat/persistent-relay-logging
ericevans-nv 334508c
Merge upstream/main into feat/persistent-relay-logging
ericevans-nv b91d8d5
Merge branch 'main' into feat/persistent-relay-logging
afourniernv d782942
feat(logging): add shared runtime configuration sources
ericevans-nv 754c33f
refactor(cli): localize logging config imports
ericevans-nv 8e04578
test(logging): move sink test out of source
ericevans-nv 07d31ee
Merge remote-tracking branch 'upstream/main' into feat/persistent-rel…
ericevans-nv 1e718ab
fix(logging): honor user config scope in discovery
ericevans-nv c093a40
fix(logging): reject conflicting global logger
ericevans-nv 5ad0ff5
Merge remote-tracking branch 'upstream/main' into feat/persistent-rel…
ericevans-nv 15e6c1d
fix(logging): reject unknown configuration fields
ericevans-nv 697a2cb
fix(logging): serialize logger lifecycle changes
ericevans-nv 6c5e76c
Merge upstream/main into feat/persistent-relay-logging
ericevans-nv 7b1a0cc
Merge upstream/main into feat/persistent-relay-logging
ericevans-nv a443ada
Merge branch 'main' into feat/persistent-relay-logging
afourniernv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| //! Process-wide operational logging arguments and source selection. | ||
|
|
||
| use std::path::{Path, PathBuf}; | ||
|
|
||
| use clap::Args; | ||
| use nemo_relay::error::FlowError; | ||
| use nemo_relay::logging::{LogFormat, LogLevel, LoggingConfig}; | ||
|
|
||
| use crate::error::CliError; | ||
|
|
||
| #[derive(Debug, Clone, Default, Args)] | ||
| pub(super) struct LoggingArgs { | ||
| /// Minimum operational log level. | ||
| #[arg( | ||
| long = "log-level", | ||
| value_parser = ["error", "warn", "info", "debug", "trace"], | ||
| conflicts_with = "config_path" | ||
| )] | ||
| level: Option<String>, | ||
| /// Format for the mandatory stderr logging sink. | ||
| #[arg( | ||
| long = "log-stderr-format", | ||
| value_parser = ["human", "jsonl"], | ||
| conflicts_with = "config_path" | ||
| )] | ||
| stderr_format: Option<String>, | ||
| /// Absolute path to a TOML document containing a `[logging]` section. | ||
| #[arg( | ||
| long = "log-config-path", | ||
| conflicts_with_all = ["level", "stderr_format"] | ||
| )] | ||
| config_path: Option<PathBuf>, | ||
| } | ||
|
|
||
| impl LoggingArgs { | ||
| /// Selects one logging source: direct CLI settings, environment, file configuration, or | ||
| /// built-in defaults. Sources are not merged with one another. | ||
| pub(super) fn resolve( | ||
| &self, | ||
| explicit_config: Option<&Path>, | ||
| user_only: bool, | ||
| ) -> Result<LoggingConfig, CliError> { | ||
| if let Some(path) = &self.config_path { | ||
| return LoggingConfig::from_file_path(path).map_err(logging_config_error); | ||
| } | ||
|
|
||
| if self.level.is_some() || self.stderr_format.is_some() { | ||
| let mut config = LoggingConfig::default(); | ||
| if let Some(level) = self.level.as_deref() { | ||
| config.level = LogLevel::parse(level).map_err(logging_config_error)?; | ||
| } | ||
| if let Some(stderr_format) = self.stderr_format.as_deref() { | ||
| config.stderr_format = | ||
| LogFormat::parse(stderr_format).map_err(logging_config_error)?; | ||
| } | ||
| return Ok(config); | ||
| } | ||
|
|
||
| if let Some(config) = LoggingConfig::from_environment().map_err(logging_config_error)? { | ||
| return Ok(config); | ||
| } | ||
|
|
||
| crate::configuration::resolve_logging_config(explicit_config, user_only) | ||
| } | ||
| } | ||
|
|
||
| fn logging_config_error(error: FlowError) -> CliError { | ||
| match error { | ||
| FlowError::InvalidArgument(message) => CliError::Config(message), | ||
| other => CliError::Flow(other), | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| //! TOML input, validation, and default inheritance for operational logging. | ||
|
|
||
| use std::path::PathBuf; | ||
|
|
||
| use nemo_relay::error::FlowError; | ||
| use nemo_relay::logging::{ | ||
| DEFAULT_FILE_FLUSH_INTERVAL_MILLIS, DEFAULT_FILE_SINK_QUEUE_ENTRIES, FileLogSinkConfig, | ||
| LogFormat, LogLevel, LogSinkConfig, LoggingConfig, MAX_FILE_SINK_QUEUE_ENTRIES, | ||
| }; | ||
| use serde::Deserialize; | ||
|
|
||
| use super::CliError; | ||
|
|
||
| #[derive(Debug, Clone, Default, Deserialize)] | ||
| #[serde(deny_unknown_fields)] | ||
| pub(super) struct FileLoggingConfig { | ||
| level: Option<String>, | ||
| stderr_format: Option<String>, | ||
| /// Optional advanced: periodic flush interval in ms applied to all file sinks (default | ||
| /// [`DEFAULT_FILE_FLUSH_INTERVAL_MILLIS`]). `0` means flush only on shutdown. | ||
| flush_interval_millis: Option<u64>, | ||
| #[serde(default)] | ||
| sinks: Vec<RawFileLogSinkConfig>, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Deserialize)] | ||
| #[serde(deny_unknown_fields)] | ||
| struct RawFileLogSinkConfig { | ||
| /// Required. Every `[[logging.sinks]]` entry is a file sink. | ||
| path: Option<PathBuf>, | ||
| level: Option<String>, | ||
| format: Option<String>, | ||
| /// Optional advanced: pending async queue entries per file sink (default | ||
| /// [`DEFAULT_FILE_SINK_QUEUE_ENTRIES`]). | ||
| queue_capacity: Option<usize>, | ||
| } | ||
|
|
||
| pub(super) fn apply_file_logging_config( | ||
| logging: &mut LoggingConfig, | ||
| config: Option<FileLoggingConfig>, | ||
| ) -> Result<(), CliError> { | ||
| let Some(config) = config else { | ||
| return Ok(()); | ||
| }; | ||
| if let Some(level) = config.level.as_deref() { | ||
| logging.level = LogLevel::parse(level).map_err(logging_parse_error)?; | ||
| } | ||
| if let Some(stderr_format) = config.stderr_format.as_deref() { | ||
| logging.stderr_format = LogFormat::parse(stderr_format).map_err(logging_parse_error)?; | ||
| } | ||
| logging.flush_interval_millis = config | ||
| .flush_interval_millis | ||
| .unwrap_or(DEFAULT_FILE_FLUSH_INTERVAL_MILLIS); | ||
| if !config.sinks.is_empty() { | ||
| let default_sink_level = logging.level; | ||
| logging.sinks = config | ||
| .sinks | ||
| .into_iter() | ||
| .map(|sink| parse_file_log_sink(sink, default_sink_level)) | ||
| .collect::<Result<Vec<_>, _>>()?; | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn parse_file_log_sink( | ||
| config: RawFileLogSinkConfig, | ||
| default_level: LogLevel, | ||
| ) -> Result<LogSinkConfig, CliError> { | ||
| let path = config | ||
| .path | ||
| .ok_or_else(|| CliError::Config("logging sink requires path".into()))?; | ||
| if path.as_os_str().is_empty() { | ||
| return Err(CliError::Config( | ||
| "logging sink path must not be empty".into(), | ||
| )); | ||
| } | ||
| let level = match config.level.as_deref() { | ||
| Some(raw) => LogLevel::parse(raw).map_err(logging_parse_error)?, | ||
| None => default_level, | ||
| }; | ||
| let format = match config.format.as_deref() { | ||
| Some(raw) => LogFormat::parse(raw).map_err(logging_parse_error)?, | ||
| None => LogFormat::Jsonl, | ||
| }; | ||
| let queue_capacity = match config.queue_capacity { | ||
| Some(0) => { | ||
| return Err(CliError::Config( | ||
| "logging sink queue_capacity must be greater than 0".into(), | ||
| )); | ||
| } | ||
| Some(capacity) if capacity > MAX_FILE_SINK_QUEUE_ENTRIES => { | ||
| return Err(CliError::Config(format!( | ||
| "logging sink queue_capacity {capacity} exceeds maximum \ | ||
| {MAX_FILE_SINK_QUEUE_ENTRIES} entries per file sink" | ||
| ))); | ||
| } | ||
| Some(capacity) => capacity, | ||
| None => DEFAULT_FILE_SINK_QUEUE_ENTRIES, | ||
| }; | ||
| Ok(LogSinkConfig::File(FileLogSinkConfig { | ||
| path, | ||
| level, | ||
| format, | ||
| queue_capacity, | ||
| })) | ||
| } | ||
|
|
||
| fn logging_parse_error(error: FlowError) -> CliError { | ||
| match error { | ||
| FlowError::InvalidArgument(message) => CliError::Config(message), | ||
| other => CliError::Flow(other), | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.