зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1436058 - Update for log 0.4 bump in WR PR 2385. r=jrmuizel
MozReview-Commit-ID: Cxkecg2cTDW --HG-- extra : rebase_source : 0b049ba3a95dda71f9d6df53ba8f636e30841fee
This commit is contained in:
Родитель
e1dbbcbce0
Коммит
bd342342df
|
@ -241,7 +241,7 @@ WebRenderAPI::InitExternalLogHandler()
|
|||
{
|
||||
// Redirect the webrender's log to gecko's log system.
|
||||
// The current log level is "error".
|
||||
mozilla::wr::wr_init_external_log_handler(wr::LogLevelFilter::Error);
|
||||
mozilla::wr::wr_init_external_log_handler(wr::WrLogLevelFilter::Error);
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
|
|
|
@ -18,7 +18,7 @@ use moz2d_renderer::Moz2dImageRenderer;
|
|||
use app_units::Au;
|
||||
use rayon;
|
||||
use euclid::SideOffsets2D;
|
||||
use log::{set_logger, shutdown_logger, LogLevelFilter, Log, LogLevel, LogMetadata, LogRecord};
|
||||
use log;
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
use dwrote::{FontDescriptor, FontWeight, FontStretch, FontStyle};
|
||||
|
@ -76,7 +76,7 @@ type WrFontInstanceKey = FontInstanceKey;
|
|||
/// cbindgen:field-names=[mNamespace, mHandle]
|
||||
type WrYuvColorSpace = YuvColorSpace;
|
||||
/// cbindgen:field-names=[mNamespace, mHandle]
|
||||
type WrLogLevelFilter = LogLevelFilter;
|
||||
type WrLogLevelFilter = log::LevelFilter;
|
||||
|
||||
fn make_slice<'a, T>(ptr: *const T, len: usize) -> &'a [T] {
|
||||
if ptr.is_null() {
|
||||
|
@ -2161,11 +2161,11 @@ struct WrExternalLogHandler {
|
|||
info_msg: ExternalMessageHandler,
|
||||
debug_msg: ExternalMessageHandler,
|
||||
trace_msg: ExternalMessageHandler,
|
||||
log_level: LogLevel,
|
||||
log_level: log::Level,
|
||||
}
|
||||
|
||||
impl WrExternalLogHandler {
|
||||
fn new(log_level: LogLevel) -> WrExternalLogHandler {
|
||||
fn new(log_level: log::Level) -> WrExternalLogHandler {
|
||||
WrExternalLogHandler {
|
||||
error_msg: gfx_critical_note,
|
||||
warn_msg: gfx_critical_note,
|
||||
|
@ -2177,39 +2177,41 @@ impl WrExternalLogHandler {
|
|||
}
|
||||
}
|
||||
|
||||
impl Log for WrExternalLogHandler {
|
||||
fn enabled(&self, metadata : &LogMetadata) -> bool {
|
||||
impl log::Log for WrExternalLogHandler {
|
||||
fn enabled(&self, metadata : &log::Metadata) -> bool {
|
||||
metadata.level() <= self.log_level
|
||||
}
|
||||
|
||||
fn log(&self, record: &LogRecord) {
|
||||
fn log(&self, record: &log::Record) {
|
||||
if self.enabled(record.metadata()) {
|
||||
// For file path and line, please check the record.location().
|
||||
let msg = CString::new(format!("WR: {}",
|
||||
record.args())).unwrap();
|
||||
unsafe {
|
||||
match record.level() {
|
||||
LogLevel::Error => (self.error_msg)(msg.as_ptr()),
|
||||
LogLevel::Warn => (self.warn_msg)(msg.as_ptr()),
|
||||
LogLevel::Info => (self.info_msg)(msg.as_ptr()),
|
||||
LogLevel::Debug => (self.debug_msg)(msg.as_ptr()),
|
||||
LogLevel::Trace => (self.trace_msg)(msg.as_ptr()),
|
||||
log::Level::Error => (self.error_msg)(msg.as_ptr()),
|
||||
log::Level::Warn => (self.warn_msg)(msg.as_ptr()),
|
||||
log::Level::Info => (self.info_msg)(msg.as_ptr()),
|
||||
log::Level::Debug => (self.debug_msg)(msg.as_ptr()),
|
||||
log::Level::Trace => (self.trace_msg)(msg.as_ptr()),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn flush(&self) {
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wr_init_external_log_handler(log_filter: WrLogLevelFilter) {
|
||||
let _ = set_logger(|max_log_level| {
|
||||
max_log_level.set(log_filter);
|
||||
Box::new(WrExternalLogHandler::new(log_filter.to_log_level()
|
||||
.unwrap_or(LogLevel::Error)))
|
||||
});
|
||||
log::set_max_level(log_filter);
|
||||
let logger = Box::new(WrExternalLogHandler::new(log_filter
|
||||
.to_level()
|
||||
.unwrap_or(log::Level::Error)));
|
||||
let _ = log::set_logger(unsafe { &*Box::into_raw(logger) });
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wr_shutdown_external_log_handler() {
|
||||
let _ = shutdown_logger();
|
||||
}
|
||||
|
|
|
@ -101,31 +101,15 @@ enum class ImageRendering : uint32_t {
|
|||
Sentinel /* this must be last for serialization purposes. */
|
||||
};
|
||||
|
||||
enum class LineOrientation : uint8_t {
|
||||
Vertical = 0,
|
||||
Horizontal = 1,
|
||||
|
||||
Sentinel /* this must be last for serialization purposes. */
|
||||
};
|
||||
|
||||
enum class LineStyle : uint8_t {
|
||||
Solid = 0,
|
||||
Dotted = 1,
|
||||
Dashed = 2,
|
||||
Wavy = 3,
|
||||
|
||||
Sentinel /* this must be last for serialization purposes. */
|
||||
};
|
||||
|
||||
// An enum representing the available verbosity level filters of the logging
|
||||
// framework.
|
||||
// An enum representing the available verbosity level filters of the logger.
|
||||
//
|
||||
// A `LogLevelFilter` may be compared directly to a [`LogLevel`](enum.LogLevel.html).
|
||||
// Use this type to [`get()`](struct.MaxLogLevelFilter.html#method.get) and
|
||||
// [`set()`](struct.MaxLogLevelFilter.html#method.set) the
|
||||
// [`MaxLogLevelFilter`](struct.MaxLogLevelFilter.html), or to match with the getter
|
||||
// [`max_log_level()`](fn.max_log_level.html).
|
||||
enum class LogLevelFilter : uintptr_t {
|
||||
// A `LevelFilter` may be compared directly to a [`Level`]. Use this type
|
||||
// to get and set the maximum log level with [`max_level()`] and [`set_max_level`].
|
||||
//
|
||||
// [`Level`]: enum.Level.html
|
||||
// [`max_level()`]: fn.max_level.html
|
||||
// [`set_max_level`]: fn.set_max_level.html
|
||||
enum class LevelFilter : uintptr_t {
|
||||
// A level lower than all log levels.
|
||||
Off = 0,
|
||||
// Corresponds to the `Error` log level.
|
||||
|
@ -142,6 +126,22 @@ enum class LogLevelFilter : uintptr_t {
|
|||
Sentinel /* this must be last for serialization purposes. */
|
||||
};
|
||||
|
||||
enum class LineOrientation : uint8_t {
|
||||
Vertical = 0,
|
||||
Horizontal = 1,
|
||||
|
||||
Sentinel /* this must be last for serialization purposes. */
|
||||
};
|
||||
|
||||
enum class LineStyle : uint8_t {
|
||||
Solid = 0,
|
||||
Dotted = 1,
|
||||
Dashed = 2,
|
||||
Wavy = 3,
|
||||
|
||||
Sentinel /* this must be last for serialization purposes. */
|
||||
};
|
||||
|
||||
enum class MixBlendMode : uint32_t {
|
||||
Normal = 0,
|
||||
Multiply = 1,
|
||||
|
@ -721,7 +721,7 @@ struct GlyphOptions {
|
|||
|
||||
using WrYuvColorSpace = YuvColorSpace;
|
||||
|
||||
using WrLogLevelFilter = LogLevelFilter;
|
||||
using WrLogLevelFilter = LevelFilter;
|
||||
|
||||
struct ByteSlice {
|
||||
const uint8_t *buffer;
|
||||
|
|
Загрузка…
Ссылка в новой задаче