Update slog and centralize log handling.
This commit is contained in:
parent
1a3e560ae1
commit
0c3bd1d001
|
@ -9,8 +9,8 @@ wayland-server = "0.9.1"
|
|||
nix = "0.7.0"
|
||||
xkbcommon = "0.2.1"
|
||||
tempfile = "2.1.5"
|
||||
slog = { version = "~1.5.2", features = ["max_level_trace", "release_max_level_info"] }
|
||||
slog-stdlog = "~1.1.0"
|
||||
slog = { version = "2.0.0", features = ["max_level_trace", "release_max_level_info"] }
|
||||
slog-stdlog = "2.0.0-0.2"
|
||||
glutin = { version = "~0.7.4", optional = true }
|
||||
glium = { version = "~0.16.0", optional = true }
|
||||
clippy = { version = "*", optional = true }
|
||||
|
|
14
src/lib.rs
14
src/lib.rs
|
@ -1,4 +1,9 @@
|
|||
#![warn(missing_docs)]
|
||||
//! # Smithay: the wayland composito smithy
|
||||
//!
|
||||
//! Most entry points in the modules can take an optionnal `slog::Logger` as argument
|
||||
//! that will be used as a drain for logging. If `None` is provided, they'll log to `slog-stdlog`.
|
||||
|
||||
|
||||
#![cfg_attr(feature = "clippy", feature(plugin))]
|
||||
#![cfg_attr(feature = "clippy", plugin(clippy))]
|
||||
|
@ -22,3 +27,12 @@ extern crate slog_stdlog;
|
|||
pub mod shm;
|
||||
pub mod backend;
|
||||
pub mod keyboard;
|
||||
|
||||
fn slog_or_stdlog<L>(logger: L) -> ::slog::Logger
|
||||
where L: Into<Option<::slog::Logger>>
|
||||
{
|
||||
use slog::Drain;
|
||||
logger
|
||||
.into()
|
||||
.unwrap_or_else(|| ::slog::Logger::root(::slog_stdlog::StdLog.fuse(), o!()))
|
||||
}
|
||||
|
|
|
@ -63,6 +63,8 @@
|
|||
|
||||
|
||||
use self::pool::{Pool, ResizeError};
|
||||
|
||||
use slog_or_stdlog;
|
||||
use std::os::unix::io::RawFd;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
@ -87,16 +89,10 @@ impl ShmGlobal {
|
|||
/// This global will always advertize `ARGB8888` and `XRGB8888` format
|
||||
/// as they are required by the protocol. Formats given as argument
|
||||
/// as additionnaly advertized.
|
||||
///
|
||||
/// An optionnal `slog::Logger` can be provided and will be used as a drain
|
||||
/// for logging. If `None` is provided, it'll log to `slog-stdlog`.
|
||||
pub fn new<L>(mut formats: Vec<wl_shm::Format>, logger: L) -> ShmGlobal
|
||||
where L: Into<Option<::slog::Logger>>
|
||||
{
|
||||
use slog::DrainExt;
|
||||
let log = logger
|
||||
.into()
|
||||
.unwrap_or_else(|| ::slog::Logger::root(::slog_stdlog::StdLog.fuse(), o!()));
|
||||
let log = slog_or_stdlog(logger);
|
||||
|
||||
// always add the mandatory formats
|
||||
formats.push(wl_shm::Format::Argb8888);
|
||||
|
|
Loading…
Reference in New Issue