Expand description
§browser_tools
Utility to log in wasm/browser.
§Logging
It integrates with JavaScript’s console
API to output log messages with varying levels of severity, enhancing the visibility and management of log data in web environments.
§Panic Handling Mechanism
Also this crate provides a debugging utility for Rust applications compiled to WebAssembly (wasm32-unknown-unknown
). It redirects panic messages to JavaScript’s console.error
, enhancing error visibility in web browsers and Node.js environments.
§Installation
Add the following to your Cargo.toml
:
[dependencies]
browser_tools = "0.2"
Modules§
- console
- exposed
- Exposed namespace of the module.
- orphan
- Orphan namespace of the module.
- own
- Own namespace of the module.
- prelude
- Prelude to use essentials:
use my_module::prelude::*
.
Macros§
- debug
- Logs a message at the debug level.
- error
- Logs a message at the error level.
- info
- Logs a message at the info level.
- log
- The standard logging macro.
- log_
enabled - Determines if a message logged at the specified level in that module will be logged.
- trace
- Logs a message at the trace level.
- warn
- Logs a message at the warn level.
Structs§
- Config
- Config of both logging and panic
- Metadata
- Metadata about a log message.
- Metadata
Builder - Builder for
Metadata
. - Parse
Level Error - The type returned by
from_str
when the string doesn’t match any of the log levels. - Record
- The “payload” of a log message.
- Record
Builder - Builder for
Record
. - SetLogger
Error - The type returned by
set_logger
ifset_logger
has already been called.
Enums§
- Level
- An enum representing the available verbosity levels of the logger.
- Level
Filter - An enum representing the available verbosity level filters of the logger.
Constants§
- STATIC_
MAX_ LEVEL - The statically resolved maximum log level.
Traits§
- Log
- A trait encapsulating the operations required of a logger.
Functions§
- logger
- Returns a reference to the logger.
- max_
level - Returns the current maximum log level.
- set_
boxed_ logger - Sets the global logger to a
Box<Log>
. - set_
logger - Sets the global logger to a
&'static Log
. - set_
logger_ ⚠racy - A thread-unsafe version of
set_logger
. - set_
max_ level - Sets the global maximum log level.
- set_
max_ ⚠level_ racy - A thread-unsafe version of
set_max_level
. - setup
- Setup both logging and panic.