Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ base.workspace = true
deno_manifest.workspace = true
graph.workspace = true

sb_event_worker = { workspace = true, optional = true, features = ["tracing"] }

anyhow.workspace = true
log.workspace = true
tokio.workspace = true
Expand All @@ -26,4 +28,4 @@ tracing-subscriber = { workspace = true, optional = true }
env_logger = "0.10.0"

[features]
tracing = ["dep:tracing-subscriber"]
tracing = ["dep:tracing-subscriber", "dep:sb_event_worker"]
5 changes: 4 additions & 1 deletion ext/event_worker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ anyhow.workspace = true
tokio.workspace = true
log.workspace = true
tracing.workspace = true
enum-as-inner.workspace = true
enum-as-inner.workspace = true

[features]
tracing = []
20 changes: 14 additions & 6 deletions ext/event_worker/js_interceptors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use deno_core::error::AnyError;
use deno_core::op2;
use deno_core::OpState;
use tokio::sync::mpsc;
use tracing::{event, trace};
use tracing::trace;

#[op2(fast)]
fn op_user_worker_log(
Expand Down Expand Up @@ -35,11 +35,19 @@ fn op_user_worker_log(
trace!(?metadata);
tx.send(metadata)?;
} else {
match level {
LogLevel::Debug => event!(tracing::Level::DEBUG, "{msg}"),
LogLevel::Info => event!(tracing::Level::INFO, "{msg}"),
LogLevel::Warning => event!(tracing::Level::WARN, "{msg}"),
LogLevel::Error => event!(tracing::Level::ERROR, "{msg}"),
#[cfg(feature = "tracing")]
{
match level {
LogLevel::Debug => tracing::event!(tracing::Level::DEBUG, "{msg}"),
LogLevel::Info => tracing::event!(tracing::Level::INFO, "{msg}"),
LogLevel::Warning => tracing::event!(tracing::Level::WARN, "{msg}"),
LogLevel::Error => tracing::event!(tracing::Level::ERROR, "{msg}"),
}
}

#[cfg(not(feature = "tracing"))]
{
log::error!("[{:?}] {}", level, msg.to_string());
}
}

Expand Down
Loading