logger.cxx 581 B

123456789101112131415161718192021222324252627282930
  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/detail/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, location_info info, message const & msg) {
  19. impl_->write({ now(), ll, info, logger_name_, msg });
  20. }
  21. void logger::flush() {
  22. impl_->flush();
  23. }
  24. }