diff --git a/Cargo.toml b/Cargo.toml index 218116d..f08f40e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 } diff --git a/src/lib.rs b/src/lib.rs index 5958779..b3ff3cd 100644 --- a/src/lib.rs +++ b/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(logger: L) -> ::slog::Logger + where L: Into> +{ + use slog::Drain; + logger + .into() + .unwrap_or_else(|| ::slog::Logger::root(::slog_stdlog::StdLog.fuse(), o!())) +} diff --git a/src/shm/mod.rs b/src/shm/mod.rs index 0660410..8d8322a 100644 --- a/src/shm/mod.rs +++ b/src/shm/mod.rs @@ -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(mut formats: Vec, logger: L) -> ShmGlobal where L: Into> { - 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);