Skip to content

Commit

Permalink
Merge #185
Browse files Browse the repository at this point in the history
185: move slog implementation into its own module r=kinggoesgaming a=kinggoesgaming

**I'm submitting a ...**
  - [ ] bug fix
  - [ ] feature enhancement
  - [ ] deprecation or removal
  - [x] refactor

# Description
The slog impl and tests are moved into `slog_support` module

# Motivation
As part of the refactor effort, feature gated implementations need to be moved into their own modules.

# Tests
Current provided tests are passing

# Related Issue(s)
#124
  • Loading branch information
bors[bot] committed Mar 26, 2018
2 parents 80bf568 + d202434 commit 0634126
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 23 deletions.
29 changes: 6 additions & 23 deletions src/lib.rs
Expand Up @@ -174,6 +174,12 @@ cfg_if! {
}
}

cfg_if! {
if #[cfg(feature = "slog")] {
mod slog_support;
}
}

cfg_if! {
if #[cfg(feature = "std")] {
mod std_support;
Expand Down Expand Up @@ -1067,18 +1073,6 @@ impl fmt::LowerHex for Uuid {
}
}

#[cfg(feature = "slog")]
impl slog::Value for Uuid {
fn serialize(
&self,
_record: &slog::Record,
key: slog::Key,
serializer: &mut slog::Serializer,
) -> Result<(), slog::Error> {
serializer.emit_arguments(key, &format_args!("{}", self))
}
}

impl<'a> fmt::Display for Simple<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::LowerHex::fmt(self, f)
Expand Down Expand Up @@ -1181,9 +1175,6 @@ mod tests {
use super::{NAMESPACE_X500, NAMESPACE_DNS, NAMESPACE_OID, NAMESPACE_URL};
use super::{Uuid, UuidVariant, UuidVersion};

#[cfg(feature = "slog")]
use slog::{self, Drain};

#[cfg(feature = "v3")]
static FIXTURE_V3: &'static [(&'static Uuid, &'static str, &'static str)] = &[
(
Expand Down Expand Up @@ -1860,12 +1851,4 @@ mod tests {
assert!(set.contains(&id1));
assert!(!set.contains(&id2));
}

#[cfg(feature = "slog")]
#[test]
fn test_slog_kv() {
let root = slog::Logger::root(slog::Discard.fuse(), o!());
let u1 = test_util::new();
crit!(root, "test"; "u1" => u1);
}
}
28 changes: 28 additions & 0 deletions src/slog_support.rs
@@ -0,0 +1,28 @@
use slog;
use Uuid;

impl slog::Value for Uuid {
fn serialize(
&self,
_: &slog::Record,
key: slog::Key,
serializer: &mut slog::Serializer,
) -> Result<(), slog::Error> {
serializer.emit_arguments(key, &format_args!("{}", self))
}
}

#[cfg(test)]
mod tests {

#[test]
fn test_slog_kv() {
use slog;
use test_util;
use slog::Drain;

let root = slog::Logger::root(slog::Discard.fuse(), o!());
let u1 = test_util::new();
crit!(root, "test"; "u1" => u1);
}
}

0 comments on commit 0634126

Please sign in to comment.