Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 692c6c4

Browse files
late logger needs to be boxed
1 parent 5768ce2 commit 692c6c4

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

‎pirt/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ edition = "2021"
88
crate-type = ["cdylib"]
99

1010
[dependencies]
11-
log = "0.4"
11+
log = { version = "0.4", features = ["std"] }

‎pirt/src/logging.rs‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ pub fn output_debug_string(msg: impl AsRef<OsStr>) {
2121
unsafe { OutputDebugStringW(msg_wide.as_ptr()); }
2222
}
2323

24-
static EARLY_LOGGER: EarlyLogger = EarlyLogger {};
25-
static LOGGER: PirtLogger = PirtLogger {};
26-
27-
fn init() {
28-
log::set_logger(&EarlyLogger);
24+
fn init() -> Result<(), String> {
25+
let early = EarlyLogger::new();
26+
log::set_boxed_logger(Box::new(early))
27+
.map_err(|e| format!("kptnhook error initializing logging: {}", e.to_string()))?;
2928
}
3029

3130
struct PirtLogger;
32-
struct EarlyLogger;
31+
struct EarlyLogger {
32+
level: Mutex<Level>
33+
}
3334

3435
impl Log for PirtLogger {
3536
fn enabled(&self, metadata: &log::Metadata) -> bool {
@@ -45,6 +46,12 @@ impl Log for PirtLogger {
4546
}
4647
}
4748

49+
impl EarlyLogger {
50+
pub fn new() -> Self {
51+
EarlyLogger { level: Mutex::new(Level::Trace) }
52+
}
53+
}
54+
4855
impl Log for EarlyLogger {
4956
fn flush(&self) { }
5057
fn enabled(&self, _: &log::Metadata) -> bool { true }

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /