1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//! A Rust library providing slog drains for sending log messages to
//! cloud-based log storages. The crate implements drains for Loggly and
//! Better Stack. Drains for custom providers can be easily implemented using
//! the `CloudDrain` type.
//!
//! # Things to be aware of
//!
//! The Loggly and Better Stack drains serialize all log messages as JSON
//! objects. If you use key-value pairs in your loggers and log messages, you
//! should know that one key-value pair can override another if they both have
//! the same key. The overrides follow this simple rule:
//! 1. Derived loggers can override key-value pairs of their ancestors.
//! 2. Log messages can override key-value pairs of their loggers.
//! 3. The latest specified key-value pair overrides everything specified
//! before.
//!
//! # Usage
//!
//! Please note that the drains are asynchronous and the log messages are
//! sent on background. If your application exits, there might be still some
//! log messages in the queue.
//!
//! ## Using the Loggly drain in an asynchronous application
//!
//! ```ignore
//! use slog::{debug, error, info, o, warn, Drain, Logger};
//! use slog_cloud::loggly::LogglyDrainBuilder;
//!
//! #[tokio::main]
//! async fn main() {
//! // Your Loggly token and tag.
//! let loggly_token = "your-loggly-token";
//! let loggly_tag = "some-app";
//!
//! // Create a custom Loggly drain.
//! let (drain, handle) = LogglyDrainBuilder::new()
//! .spawn_task(loggly_token, loggly_tag)
//! .unwrap();
//!
//! // Create a logger.
//! let logger = Logger::root(drain.fuse(), o!());
//!
//! debug!(logger, "debug"; "key" => "value");
//! info!(logger, "info"; "key" => "value");
//! warn!(logger, "warn"; "key" => "value");
//! error!(logger, "error"; "key" => "value");
//!
//! // Flush all log messages.
//! handle.flush().await;
//! }
//! ```
//!
//! ## Using the Loggly drain in a normal application
//!
//! ```ignore
//! use slog::{debug, error, info, o, warn, Drain, Logger};
//! use slog_cloud::loggly::LogglyDrainBuilder;
//!
//! // Your Loggly token and tag.
//! let loggly_token = "your-loggly-token";
//! let loggly_tag = "some-app";
//!
//! // Create a custom Loggly drain.
//! let (drain, handle) = LogglyDrainBuilder::new()
//! .spawn_thread(loggly_token, loggly_tag)
//! .unwrap();
//!
//! // Create a logger.
//! let logger = Logger::root(drain.fuse(), o!());
//!
//! debug!(logger, "debug"; "key" => "value");
//! info!(logger, "info"; "key" => "value");
//! warn!(logger, "warn"; "key" => "value");
//! error!(logger, "error"; "key" => "value");
//!
//! // Flush all log messages.
//! handle.blocking_flush();
//! ```
//!
//! ## Using the Better Stack drain
//!
//! The Better Stack drain usage is analogous to the Loggly drain.
pub use ;