-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: dierbei <[email protected]>
- Loading branch information
Showing
7 changed files
with
130 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod log; | ||
pub mod network; | ||
pub mod server; | ||
pub mod storage; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use chrono::prelude::*; | ||
use slog::{o, Drain, Logger}; | ||
|
||
pub fn get_logger() -> Logger { | ||
let decorator = slog_term::PlainSyncDecorator::new(std::io::stdout()); | ||
let drain = slog_term::FullFormat::new(decorator) | ||
.use_custom_timestamp(|io| write!(io, "{}", Utc::now().format("%Y-%m-%d %H:%M:%S"))) | ||
.build() | ||
.fuse(); | ||
|
||
Logger::root(drain, o!()) | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use slog::{crit, debug, error, info, trace, warn}; | ||
|
||
use crate::log::get_logger; | ||
|
||
#[tokio::test] | ||
async fn test_slog() { | ||
let log = get_logger(); | ||
|
||
trace!(log, "trace log message"); | ||
debug!(log, "debug log message"); | ||
info!(log, "info log message"); | ||
warn!(log, "warn log message"); | ||
error!(log, "error log message"); | ||
crit!(log, "crit log message"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.