summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorClementTsang <clementjhtsang@gmail.com>2019-09-11 23:34:26 -0400
committerClementTsang <clementjhtsang@gmail.com>2019-09-11 23:34:26 -0400
commit71ac3313e47ee14a3a73d541e2acd309267b3762 (patch)
tree229e129218e2ac5a7cdf29a757674f0747e31f2e /src/utils
parent691c887b5649c2e582df493fb06e1097ea274095 (diff)
More refactoring; added logging and error files.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/error.rs1
-rw-r--r--src/utils/logging.rs17
2 files changed, 18 insertions, 0 deletions
diff --git a/src/utils/error.rs b/src/utils/error.rs
new file mode 100644
index 00000000..1d5c9e9f
--- /dev/null
+++ b/src/utils/error.rs
@@ -0,0 +1 @@
+pub struct RustopError {}
diff --git a/src/utils/logging.rs b/src/utils/logging.rs
new file mode 100644
index 00000000..af4cf302
--- /dev/null
+++ b/src/utils/logging.rs
@@ -0,0 +1,17 @@
+pub fn init_logger() -> Result<(), fern::InitError> {
+ fern::Dispatch::new()
+ .format(|out, message, record| {
+ out.finish(format_args!(
+ "{}[{}][{}] {}",
+ chrono::Local::now().format("[%Y-%m-%d][%H:%M:%S]"),
+ record.target(),
+ record.level(),
+ message
+ ))
+ })
+ .level(if cfg!(debug_assertions) { log::LevelFilter::Debug } else { log::LevelFilter::Info })
+ .chain(fern::log_file("debug.log")?)
+ .apply()?;
+
+ Ok(())
+}