Files
zed/crates/gpui_web/src/logging.rs
T
Ben Kunkle 9ac5425e90 Remove CRLF line endings (#57680)
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #ISSUE

Release Notes:

- N/A or Added/Fixed/Improved ...
2026-05-26 12:59:21 +00:00

38 lines
969 B
Rust

use log::{Level, Log, Metadata, Record};
struct ConsoleLogger;
impl Log for ConsoleLogger {
fn enabled(&self, _metadata: &Metadata) -> bool {
true
}
fn log(&self, record: &Record) {
if !self.enabled(record.metadata()) {
return;
}
let message = format!(
"[{}] {}: {}",
record.level(),
record.target(),
record.args()
);
let js_string = wasm_bindgen::JsValue::from_str(&message);
match record.level() {
Level::Error => web_sys::console::error_1(&js_string),
Level::Warn => web_sys::console::warn_1(&js_string),
Level::Info => web_sys::console::info_1(&js_string),
Level::Debug | Level::Trace => web_sys::console::log_1(&js_string),
}
}
fn flush(&self) {}
}
pub fn init_logging() {
log::set_logger(&ConsoleLogger).ok();
log::set_max_level(log::LevelFilter::Info);
}