feat: add tracing logger

This commit is contained in:
2023-05-02 20:10:43 +02:00
parent 91097868dc
commit f670989a46
4 changed files with 26 additions and 5 deletions

View File

@@ -7,14 +7,20 @@ use dagger_core::engine::Engine as DaggerEngine;
use crate::errors::ConnectError;
use crate::gen::Query;
use crate::logging::StdLogger;
use crate::logging::{StdLogger, TracingLogger};
use crate::querybuilder::query;
pub type DaggerConn = Arc<Query>;
pub async fn connect() -> Result<DaggerConn, ConnectError> {
let cfg = if cfg!(feature = "otel") {
let cfg = Config::new(None, None, None, None, Some(Arc::new(StdLogger::default())));
let cfg = Config::new(
None,
None,
None,
None,
Some(Arc::new(TracingLogger::default())),
);
#[cfg(feature = "otel")]
crate::logging::otel_logging().map_err(ConnectError::FailedToInstallOtelTracer)?;

View File

@@ -61,13 +61,13 @@ impl Default for TracingLogger {
impl Logger for TracingLogger {
fn stdout(&self, output: &str) -> eyre::Result<()> {
tracing::info!(output = output, "dagger-sdk");
tracing::info!(output = output, "dagger_sdk");
Ok(())
}
fn stderr(&self, output: &str) -> eyre::Result<()> {
tracing::warn!(output = output, "dagger-sdk");
tracing::warn!(output = output, "dagger_sdk");
Ok(())
}