mirror of
https://codeberg.org/Toasterson/solstice-ci.git
synced 2026-04-10 21:30:41 +00:00
- Add `logs-service` crate as a separate microservice to handle job log storage, retrieval, and categorization. - Update orchestrator to redirect log endpoints to the new service with optional permanent redirects using `LOGS_BASE_URL`. - Enhance log persistence by introducing structured fields such as category, level, and error flags. - Implement migration to add new columns and indexes for job logs. - Add ANSI escape sequence stripping and structured logging for cleaner log storage. - Improve SSH log handling with interleaved stdout/stderr processing and pty request support. - Revise Docker files and compose setup to include logs-service, with support for PostgreSQL and secure connections. Signed-off-by: Till Wegmueller <toasterson@gmail.com>
29 lines
986 B
Rust
29 lines
986 B
Rust
use tracing_subscriber::{EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt};
|
|
|
|
/// Guard that keeps non-blocking writer alive and allows flushing on drop
|
|
pub struct TelemetryGuard {
|
|
// Drop to flush writer.
|
|
_guard: Option<tracing_appender::non_blocking::WorkerGuard>,
|
|
}
|
|
|
|
/// Initialize tracing. Console-only for now; OTEL can be wired later.
|
|
pub fn init_tracing(_service_name: &str) -> miette::Result<TelemetryGuard> {
|
|
let (nb_writer, guard) = tracing_appender::non_blocking(std::io::stderr());
|
|
|
|
let fmt_layer = fmt::layer()
|
|
.with_target(false)
|
|
.with_writer(nb_writer)
|
|
// Force-disable ANSI to keep logs plain for serial capture and gRPC forwarding
|
|
.with_ansi(false);
|
|
|
|
let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));
|
|
|
|
tracing_subscriber::registry()
|
|
.with(filter)
|
|
.with(fmt_layer)
|
|
.init();
|
|
|
|
Ok(TelemetryGuard {
|
|
_guard: Some(guard),
|
|
})
|
|
}
|