Skip to content

Commit

Permalink
Logging finalisations, js cdn works
Browse files Browse the repository at this point in the history
  • Loading branch information
zakstucke committed Feb 20, 2024
1 parent 6ba1092 commit 5363016
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
6 changes: 5 additions & 1 deletion js/bitbazaar/log/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ class GlobalLog {
if (this.console.custom_out) {
emitter = this.console.custom_out;
}
emitter(message, attributes);
if (attributes !== undefined) {
emitter(message, attributes);
} else {
emitter(message);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions js/package-lock.json

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

33 changes: 22 additions & 11 deletions rust/bitbazaar/log/global_log/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,36 @@ pub fn builder_into_global_log(builder: GlobalLogBuilder) -> Result<GlobalLog, A

match output {
super::builder::Output::Stdout(stdout) => {
// When not web, normal std out and non-blocking:
// When not web, normal std out, color and non-blocking:
#[cfg(not(target_arch = "wasm32"))]
let writer = {
{
let (writer, _guard) = tracing_appender::non_blocking(std::io::stdout());
guards.push(_guard);
writer
add_layer!(
stdout.shared,
create_fmt_layer(stdout.pretty, false, stdout.include_loc, true, writer)?
);
};

// When web, custom console writer, non-blocking doesn't seem to be supported on web (raises runtime):
// When web:
// - custom console writer
// - no color: current practice is js logging, which will be hooking into this console logger, so color would ruin otlp output
// - non-blocking as doesn't seem to be supported on web (raises runtime):
#[cfg(target_arch = "wasm32")]
let writer = {
{
use tracing_subscriber_wasm::MakeConsoleWriter;
MakeConsoleWriter::default()
};

add_layer!(
stdout.shared,
create_fmt_layer(stdout.pretty, false, stdout.include_loc, true, writer,)?
);
add_layer!(
stdout.shared,
create_fmt_layer(
stdout.pretty,
false,
stdout.include_loc,
false,
MakeConsoleWriter::default()
)?
);
};
}
// File obvs can't be written in wasm, excluding to keep tracing_appender out of build etc.
#[cfg(target_arch = "wasm32")]
Expand Down

0 comments on commit 5363016

Please sign in to comment.