forked from feather-rs/feather
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.rs
More file actions
30 lines (24 loc) · 751 Bytes
/
Copy pathlog.rs
File metadata and controls
30 lines (24 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use crate::vtable::vtable;
use fapi_common::log::LogLevel;
use fapi_common::util::FStr;
use log::{Log, Metadata, Record};
/// A logging instance which delegates log messages
/// to the host's logging infrastructure.
pub struct HostLogger;
pub static HOST: HostLogger = HostLogger;
impl Log for HostLogger {
fn enabled(&self, _metadata: &Metadata) -> bool {
true
}
fn log(&self, record: &Record) {
let level = LogLevel::from(record.level());
let msg = format!("{}", record.args());
let module_path = record.module_path_static().unwrap_or("");
unsafe {
vtable().log(level, FStr::from(msg.as_str()), module_path.into());
}
}
fn flush(&self) {
// empty
}
}