mpv logging
This commit is contained in:
parent
28b7bbdf60
commit
f18c413457
3 changed files with 17 additions and 1 deletions
|
@ -48,7 +48,7 @@ pub struct LogMessageEvent {
|
|||
pub prefix: String,
|
||||
pub level: String,
|
||||
pub text: String,
|
||||
//log_level: i32,
|
||||
pub log_level: u32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
|
@ -188,6 +188,7 @@ impl Handle {
|
|||
text: unsafe { CStr::from_ptr(data.text) }
|
||||
.to_string_lossy()
|
||||
.into(),
|
||||
log_level: data.log_level,
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
|
@ -169,6 +169,21 @@ mod imp {
|
|||
_ => unreachable!(),
|
||||
},
|
||||
|
||||
Event::LogMessage(event) => {
|
||||
// TODO: levels etc
|
||||
if event.log_level < 30 {
|
||||
event!(target: "mpv", Level::ERROR, "[{}] {}", event.prefix, event.text.trim());
|
||||
} else if event.log_level < 40 {
|
||||
event!(target: "mpv", Level::WARN, "[{}] {}", event.prefix, event.text.trim());
|
||||
} else if event.log_level < 50 {
|
||||
event!(target: "mpv", Level::INFO, "[{}] {}", event.prefix, event.text.trim());
|
||||
} else if event.log_level < 70 {
|
||||
event!(target: "mpv", Level::DEBUG, "[{}] {}", event.prefix, event.text.trim());
|
||||
} else {
|
||||
event!(target: "mpv", Level::TRACE, "[{}] {}", event.prefix, event.text.trim());
|
||||
};
|
||||
}
|
||||
|
||||
_ => event!(Level::DEBUG, "unhandled {event:?}"),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue