cicadahq/cicada

Add structured logging

Closed this issue · 0 comments

Right now we are just using println! for all of our logging, what we want to do is support a structured logging format. To do this we will leverage tracing and tracing_subscriber.

  1. Replace all println! with an equivalent tracing event
  2. Create a custom tracing subscriber that emits logs like we currently have
    • Trace/Debug should not log
    • Info should be unformatted
      • It should be prefixed by the job if in a job, to know if it is in a job use spans
    • Warn/Error should be prefixed with that level
    • We want the events and spans to have metadata, we can create this in a strongly typed manor using the valuable API
  3. Add support to the CLI for json logging using the default Json formatter
    • This can either be with a cli flag like -f json or an env var

I imagine in code this will look something like this, the metadata should prob be more structured though via the valuable trait.

info!("Just a log line", type%="pipeline_start");
{
	let _job_span = span!("Job Name", type=%"job_span");
	info!("Log from job", type=%"job_log", stream=%"stdout");
}
info!("All done!", type=%"pipeline_end");
Just a log line
Job Name: Log from job
All done