You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lib.rs 1.1KB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //! Tools to record and display what's happening in your program
  2. //!
  3. #![feature(test)]
  4. #[macro_use] extern crate slog;
  5. #[macro_use] extern crate money;
  6. extern crate test;
  7. extern crate zmq;
  8. extern crate influent;
  9. extern crate chrono;
  10. extern crate hyper;
  11. extern crate termion;
  12. extern crate pub_sub;
  13. extern crate sloggers;
  14. extern crate windows;
  15. use std::sync::Arc;
  16. use chrono::{DateTime, Utc};
  17. use sloggers::Build;
  18. use sloggers::types::{Severity, TimeZone};
  19. use sloggers::file::FileLoggerBuilder;
  20. pub mod influx;
  21. pub mod warnings;
  22. pub mod latency;
  23. //pub type FileLogger = slog::Logger<Arc<slog::SendSyncRefUnwindSafeDrain<Ok=(), Err=slog::private::NeverStruct>>>;
  24. /// converts a chrono::DateTime to an integer timestamp (ns)
  25. ///
  26. pub fn nanos(t: DateTime<Utc>) -> u64 {
  27. (t.timestamp() as u64) * 1_000_000_000_u64 + (t.timestamp_subsec_nanos() as u64)
  28. }
  29. pub fn file_logger(path: &'static str) -> slog::Logger {
  30. let mut builder = FileLoggerBuilder::new(path);
  31. builder.level(Severity::Debug);
  32. builder.timezone(TimeZone::Utc);
  33. builder.build().unwrap()
  34. }