Open
Bug 1358068
Opened 8 years ago
Updated 2 years ago
Output log to prlog buffer
Categories
(Core :: Audio/Video: Playback, enhancement, P3)
Core
Audio/Video: Playback
Tracking
()
NEW
People
(Reporter: ayang, Unassigned)
References
(Depends on 1 open bug)
Details
Currently, mp4 rust parser dumps log to console, in some systems like android, it won't output to console. We should dump log to prlog buffer.
Reporter | ||
Comment 1•8 years ago
|
||
To do this, mp4parser needs to call MOZ_LOG in gecko. However, cheddar doesn't support calling c++ function from rust.
I guess we need to use FFI or bindgen to wrap it?
Flags: needinfo?(giles)
Comment 2•8 years ago
|
||
We can avoid needing to call c++ by expanding the mp4parse logging. Add a `set_debug_logger(log: fn(msg: &str))` function to mp4parse which registers a callback which the log! macro will call. Add a similar function to mp4parse_capi to translate `msg` into a C string.
Alternatively, have the log macro accumulate messages in a buffer, and add a function clients can call to retrieve the log if there's an error.
This lets us keep the glue code which needs to call C++ in C++, and makes logging more useful for other pure rust users of mp4parse, like servo. However, it doesn't help us move more of MP4Metadata into Rust code.
Another idea is to write a rust crate that implements the Log trait (https://docs.rs/log) on top of MOZ_LOG (probably a wrapper around mozilla::LazyLogModule which I think goes through xpcom/base/Logging.cpp these days instead of nspr). Then everyone can use it. It looks like the servo code is using `env_logger` which just writes to stderr, so this would be a useful improvement.
We're not currently supporting bindgen at build time, but this might be a reason to start, since we'll have to turn it on eventually. In the meantime you can run it locally and check in the generated code.
Emilio, any comments on how the stylo stuff is doing logging? Does anything talking to MOZ_LOG already exist?
Flags: needinfo?(giles) → needinfo?(emilio+bugs)
Comment 3•8 years ago
|
||
Not as far as I know, we initialize logging to stderr here:
* https://github.com/servo/servo/blob/8bfcc6992e2bf4c115e6bf3307d8ed3f6ddf24f8/ports/geckolib/glue.rs#L110
And the build system has its own optional logging to debug build issues, but that's another thing.
Wouldn't be extremely hard to hook into MOZ_LOG as far as I know, you only need a custom Logger implementation.
Flags: needinfo?(emilio+bugs)
Reporter | ||
Comment 4•8 years ago
|
||
Ok, I'll change parser to use Log trait and then implement a crate which binds the Gecko mozilla::LazyLogModule to Log trait's implementation.
Updated•8 years ago
|
Priority: -- → P3
Comment 5•3 years ago
|
||
The bug assignee is inactive on Bugzilla, so the assignee is being reset.
Assignee: ayang → nobody
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•