logger.cxx 709 B

1234567891011121314151617181920212223242526272829303132333435
  1. //
  2. // logger.cpp
  3. // logger
  4. //
  5. // Created by Sam Jaffe on 9/3/16.
  6. //
  7. #include "logger/logger.h"
  8. #include "common.h"
  9. #include "logger_impl.h"
  10. #include "logger/logpacket.h"
  11. namespace logging {
  12. logger::logger(std::string const & name, std::shared_ptr<logger_impl> impl)
  13. : logger_name_(name), impl_(impl) {
  14. }
  15. logger::~logger() {
  16. if (impl_) impl_->flush();
  17. }
  18. void logger::log(level ll, message const & msg) {
  19. impl_->write({ now(), ll, {}, logger_name_, msg });
  20. }
  21. void logger::log(level ll, location_info const & info,
  22. message const & msg) {
  23. impl_->write({ now(), ll, info, logger_name_, msg });
  24. }
  25. void logger::flush() {
  26. impl_->flush();
  27. }
  28. }