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"
|
nix = "0.7.0"
|
||||||
xkbcommon = "0.2.1"
|
xkbcommon = "0.2.1"
|
||||||
tempfile = "2.1.5"
|
tempfile = "2.1.5"
|
||||||
slog = { version = "~1.5.2", features = ["max_level_trace", "release_max_level_info"] }
|
slog = { version = "2.0.0", features = ["max_level_trace", "release_max_level_info"] }
|
||||||
slog-stdlog = "~1.1.0"
|
slog-stdlog = "2.0.0-0.2"
|
||||||
glutin = { version = "~0.7.4", optional = true }
|
glutin = { version = "~0.7.4", optional = true }
|
||||||
glium = { version = "~0.16.0", optional = true }
|
glium = { version = "~0.16.0", optional = true }
|
||||||
clippy = { version = "*", optional = true }
|
clippy = { version = "*", optional = true }
|
||||||
|
|
14
src/lib.rs
14
src/lib.rs
|
@ -1,4 +1,9 @@
|
||||||
#![warn(missing_docs)]
|
#![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", feature(plugin))]
|
||||||
#![cfg_attr(feature = "clippy", plugin(clippy))]
|
#![cfg_attr(feature = "clippy", plugin(clippy))]
|
||||||
|
@ -22,3 +27,12 @@ extern crate slog_stdlog;
|
||||||
pub mod shm;
|
pub mod shm;
|
||||||
pub mod backend;
|
pub mod backend;
|
||||||
pub mod keyboard;
|
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 self::pool::{Pool, ResizeError};
|
||||||
|
|
||||||
|
use slog_or_stdlog;
|
||||||
use std::os::unix::io::RawFd;
|
use std::os::unix::io::RawFd;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
@ -87,16 +89,10 @@ impl ShmGlobal {
|
||||||
/// This global will always advertize `ARGB8888` and `XRGB8888` format
|
/// This global will always advertize `ARGB8888` and `XRGB8888` format
|
||||||
/// as they are required by the protocol. Formats given as argument
|
/// as they are required by the protocol. Formats given as argument
|
||||||
/// as additionnaly advertized.
|
/// 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
|
pub fn new<L>(mut formats: Vec<wl_shm::Format>, logger: L) -> ShmGlobal
|
||||||
where L: Into<Option<::slog::Logger>>
|
where L: Into<Option<::slog::Logger>>
|
||||||
{
|
{
|
||||||
use slog::DrainExt;
|
let log = slog_or_stdlog(logger);
|
||||||
let log = logger
|
|
||||||
.into()
|
|
||||||
.unwrap_or_else(|| ::slog::Logger::root(::slog_stdlog::StdLog.fuse(), o!()));
|
|
||||||
|
|
||||||
// always add the mandatory formats
|
// always add the mandatory formats
|
||||||
formats.push(wl_shm::Format::Argb8888);
|
formats.push(wl_shm::Format::Argb8888);
|
||||||
|
|
Loading…
Reference in New Issue