Skip to content
This repository was archived by the owner on Oct 17, 2022. It is now read-only.

Commit 63294d3

Browse files
Rework using the POSIX syslog API. This is a breaking change.
As discussed in PR slog-rs#5, this is based on the [syslog backend that I wrote for sloggers][1] and does not use the `syslog` crate. It is now very different from both slog-syslog 0.12 and PR slog-rs#5. Differences from slog-rs#5 include: * Uses the POSIX syslog API through the `libc` crate. (See “design and rationale” in src/lib.rs, starting at line 52, for details.) This means: * Only works on Unix-like platforms. * Only sends log messages to the local syslog daemon, not to a remote server. * Formats log messages into a reusable thread-local buffer, as in slog-syslog 0.12. * The `Drain` implementation is now called `SyslogDrain` instead of `Streamer3164`, since local syslog doesn't use the RFC3164 protocol. * If the `serde` feature is enabled, logging settings can be loaded from a configuration file. Minimum supported Rust version is 1.27.2, or if the `serde` feature is enabled, 1.31.0. Doc-tests require 1.28.0. Works (except doc-tests) on 1.26.2 if you run the following commands first: ``` cargo generate-lockfile cargo update --package lazy_static --precise 1.3.0 cargo update --package serde --precise 1.0.58 cargo update --package serde_derive --precise 1.0.58 ``` [1]: sile/sloggers#34
1 parent 6327dd4 commit 63294d3

File tree

12 files changed

+2081
-295
lines changed

12 files changed

+2081
-295
lines changed

Cargo.toml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
[package]
22
name = "slog-syslog"
3-
version = "0.12.0"
3+
version = "0.13.0"
44
authors = ["Dawid Ciężarkiewicz <dpc@dpc.pw>", "William Laeder <codylaeder@gmail.com" ]
55
description = "Syslog drain for slog-rs"
66
keywords = ["slog", "logging", "json", "log", "syslog"]
77
license = "MPL-2.0"
8-
documentation = "https://docs.rs/slog-rs/term"
8+
documentation = "https://docs.rs/slog-syslog"
99
homepage = "https://github.com/slog-rs/slog"
1010
repository = "https://github.com/slog-rs/syslog"
1111
readme = "README.md"
1212

13-
[lib]
14-
path = "lib.rs"
15-
1613
[dependencies]
14+
lazy_static = "1"
15+
libc = "0.2"
16+
serde = { version = "1", optional = true, features = ["derive"] }
1717
slog = "^2.1.1"
18-
syslog = "3.3.0"
19-
nix = "0.14.0"
18+
19+
[dev-dependencies]
20+
toml = "0.4"
21+
22+
[package.metadata.docs.rs]
23+
all-features = true

Makefile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,29 @@ CARGO_FLAGS += --release
1515
else
1616
$(info DEBUG BUILD: $(PKG_NAME); use `RELEASE=true make [args]` for release build)
1717
endif
18+
CARGO_FEATURES=serde
1819

1920
EXAMPLES = $(shell cd examples 2>/dev/null && ls *.rs 2>/dev/null | sed -e 's/.rs$$//g' )
2021

2122
all: $(ALL_TARGETS)
2223

2324
.PHONY: run test build doc clean clippy
24-
run test build clean:
25+
run test build:
26+
cargo $@ --features $(CARGO_FEATURES) $(CARGO_FLAGS)
27+
28+
clean:
2529
cargo $@ $(CARGO_FLAGS)
2630

2731
check:
2832
$(info Running check; use `make build` to actually build)
29-
cargo $@ $(CARGO_FLAGS)
33+
cargo $@ --features $(CARGO_FEATURES) $(CARGO_FLAGS)
3034

3135
clippy:
32-
cargo build --features clippy
36+
cargo build --features clippy,$(CARGO_FEATURES)
3337

3438
.PHONY: bench
3539
bench:
36-
cargo $@ $(filter-out --release,$(CARGO_FLAGS))
40+
cargo $@ --features $(CARGO_FEATURES) $(filter-out --release,$(CARGO_FLAGS))
3741

3842
.PHONY: travistest
3943
travistest: test
@@ -50,7 +54,7 @@ $(EXAMPLES):
5054

5155
.PHONY: doc
5256
doc: FORCE
53-
cargo doc
57+
cargo --features $(CARGO_FEATURES) doc
5458

5559
.PHONY: publishdoc
5660
publishdoc:

examples/syslog-unix.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
extern crate slog;
33
extern crate slog_syslog;
44

5-
use slog::Drain;
6-
use slog_syslog::Facility;
5+
use slog_syslog::{Facility, SyslogBuilder};
76

87
fn main() {
9-
let syslog = slog_syslog::unix_3164(Facility::LOG_USER).unwrap();
10-
let root = slog::Logger::root(syslog.fuse(), o!());
8+
let syslog = SyslogBuilder::new().facility(Facility::User).build();
9+
let root = slog::Logger::root(syslog, o!());
1110

1211
info!(root, "Starting");
1312

lib.rs

Lines changed: 0 additions & 279 deletions
This file was deleted.

0 commit comments

Comments
 (0)