Why not compatible with log crate? #3

Closed
opened 2020-11-13 09:35:29 +00:00 by totalkrill · 1 comment

as title, is there a specific reason to not be compatible with log?

as title, is there a specific reason to not be compatible with log?
Owner

Hi totalkrill,

The goal of this crate is to integrate as closely as possible with the browser's Console API. This means being able to interact with the API directly, including being able to pass references to JavaScript objects, primitives of various types, and so on.

The Log trait by design only exposes an opaque data structure to implementations which AFAICT doesn't allow access to the original arguments. This means they can't be passed over the JS boundary, and have to be stringified in Rust first.

I suppose that it would be possible to expose a simple wrapper that implements the Log trait, but it would be quite limited in functionality.

There is also the consideration that the Console API contains a lot more than just logging primitives (e.g. assertions, counters, timers, etc.)

An alternative Wasm logging crate which is log-compatible is https://crates.io/crates/wasm-logger.

Hi totalkrill, The goal of this crate is to integrate as closely as possible with the browser's Console API. This means being able to interact with the API directly, including being able to pass references to JavaScript objects, primitives of various types, and so on. The Log trait by design only exposes an [opaque data structure](https://doc.rust-lang.org/beta/core/fmt/struct.Arguments.html) to implementations which AFAICT doesn't allow access to the original arguments. This means they can't be passed over the JS boundary, and have to be stringified in Rust first. I suppose that it would be possible to expose a simple wrapper that implements the Log trait, but it would be quite limited in functionality. There is also the consideration that the Console API contains a lot more than just logging primitives (e.g. assertions, counters, timers, etc.) An alternative Wasm logging crate which is log-compatible is https://crates.io/crates/wasm-logger.
rob added the
question
label 2020-11-13 16:29:08 +00:00
rob closed this issue 2020-11-18 10:38:57 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: rob/weblog#3
No description provided.