v0.1.4-pre.016

This commit is contained in:
2026-08-16 19:00:49 +02:00
parent d92eb01bc2
commit 5aa538ed5d
29 changed files with 994 additions and 73 deletions

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-logging-lib/tests/public_api.rs
// version: 6
// version: 7
//! Integration tests for the public crate-root surface of `ksp-logging-lib`.
@@ -81,10 +81,16 @@ fn all_span_levels_are_usable() {
#[test]
fn public_runtime_surface_is_addressable_without_installing_it() {
let _initialize = ksp_logging_lib::initialize;
let _initialize_with_identity = ksp_logging_lib::initialize_with_identity;
let _reinitialize = ksp_logging_lib::reinitialize;
let identity = ksp_logging_lib::LoggingRuntimeIdentity::new("ksp-test", "20260816-182519.123Z-p4242");
assert!(identity.is_ok());
let _already_initialized = ksp_logging_lib::ERROR_CODE_ALREADY_INITIALIZED;
let _invalid_runtime_identity = ksp_logging_lib::ERROR_CODE_INVALID_RUNTIME_IDENTITY;
let _reload_failed = ksp_logging_lib::ERROR_CODE_RELOAD_FAILED;
let _file_initialization_failed = ksp_logging_lib::ERROR_CODE_FILE_OUTPUT_INITIALIZATION_FAILED;
let _runtime_identity = ksp_logging_lib::LoggingGuard::runtime_identity;
let _active_file_outputs = ksp_logging_lib::LoggingGuard::active_file_outputs;
let _per_file_counter = ksp_logging_lib::LoggingGuard::dropped_file_lines;
let dropped = ksp_logging_lib::DroppedLines::zero();
assert_eq!(dropped.console(), 0);

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-logging-lib/tests/runtime.rs
// version: 8
// version: 9
//! Integration tests for global initialization, takeover filtering, non-blocking outputs and hot reload.
@@ -119,7 +119,13 @@ fn global_runtime_supports_takeover_non_blocking_outputs_hot_reload_and_single_i
std::option::Option::None,
std::vec::Vec::new(),
);
let initialize_result = ksp_logging_lib::initialize(&disabled);
let identity = ksp_logging_lib::LoggingRuntimeIdentity::new("ksp-logging-runtime-test", "20260816-182519.123Z-p4242");
assert!(identity.is_ok());
let identity = match identity {
std::result::Result::Ok(value) => value,
std::result::Result::Err(_) => return,
};
let initialize_result = ksp_logging_lib::initialize_with_identity(&disabled, &identity);
assert!(initialize_result.is_ok());
let mut guard = match initialize_result {
std::result::Result::Ok(guard) => guard,
@@ -222,6 +228,12 @@ fn global_runtime_supports_takeover_non_blocking_outputs_hot_reload_and_single_i
);
let file_reload = ksp_logging_lib::reinitialize(&mut guard, &files_enabled);
assert!(file_reload.is_ok());
assert_eq!(guard.runtime_identity(), std::option::Option::Some(&identity));
let active_files = guard.active_file_outputs();
assert_eq!(active_files.len(), 4);
for file in &active_files {
assert!(file.file_name_prefix().starts_with("ksp-logging-runtime-test.20260816-182519.123Z-p4242."));
}
ksp_logging_lib::info!(target: LOGGING_TARGET, "logging info \x1b[31mmarker\x1b[0m");
ksp_logging_lib::error!(target: LOGGING_TARGET, "logging error marker");
ksp_logging_lib::info!(target: JSON_KSP_TARGET, "json info marker");