log_manager.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // log_manager.hpp
  3. // logging
  4. //
  5. // Created by Sam Jaffe on 4/1/19.
  6. //
  7. #pragma once
  8. #include <memory>
  9. #include <string>
  10. namespace objects { namespace prototype {
  11. template <typename, typename...> class factory;
  12. }}
  13. namespace logging {
  14. class appender;
  15. class c_logger;
  16. class layout;
  17. class logger;
  18. class properties;
  19. /**
  20. * A singleton object that is designed for use constructing the various
  21. * loggers. At program start time, the programmer should provide the
  22. * configuration properties to the manager. Once the configuration has been
  23. * applied, you can then request loggers from the system.
  24. * TODO: Have manager automatically check certain locations for a config file
  25. */
  26. class manager {
  27. private:
  28. std::unique_ptr<struct manager_impl> pimpl_;
  29. public:
  30. static manager & instance();
  31. /**
  32. * Functions to construct logger handles for use. When providing an unknown
  33. * logger name, the default logger_impl will be used instead (with the given
  34. * name wrapped around it).
  35. */
  36. logger get(std::string const & name = "");
  37. c_logger c_get(std::string const & name = "");
  38. void configure(properties const & props);
  39. manager();
  40. ~manager();
  41. };
  42. using appenders = objects::prototype::factory<std::shared_ptr<appender>,
  43. properties const &>;
  44. using layouts =
  45. objects::prototype::factory<std::shared_ptr<layout>, properties const &>;
  46. }