gcplog-rs
A Rust tracing subscriber that emits logs to stderr as newline-delimited JSON in the format expected by Google Cloud Logging.
Usage
use tracing::info;
fn main() {
gcplog_rs::init(gcplog_rs::Config::new());
info!("Application started");
}
With explicit project ID:
gcplog_rs::init(gcplog_rs::Config::with_project_id("my-project-123"));
With custom log level:
use tracing_subscriber::filter::LevelFilter;
gcplog_rs::init(
gcplog_rs::Config::with_project_id("my-project-123")
.with_level(LevelFilter::DEBUG)
);
Trace Correlation
To correlate logs with traces, create spans with a trace_id
field:
use tracing::info_span;
let span = info_span!("trace_id", trace_id = %"abc123");
let _guard = span.enter();
info!("This log will include the trace ID");
Output Format
Logs are emitted as JSON:
{
"severity": "INFO",
"message": "Application started",
"time": "2025-10-15T21:05:13.661Z",
"logging.googleapis.com/sourceLocation": {
"file": "src/main.rs",
"line": "10",
"function": "my_app"
},
"logging.googleapis.com/trace": "projects/my-project/traces/abc123"
}