dinit-log.h 875 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef DINIT_LOG_H
  2. #define DINIT_LOG_H
  3. // Logging for Dinit
  4. #include <string>
  5. enum class LogLevel {
  6. DEBUG,
  7. INFO,
  8. WARN,
  9. ERROR,
  10. ZERO // log absolutely nothing
  11. };
  12. extern LogLevel log_level;
  13. extern bool log_to_console;
  14. void log(LogLevel lvl, const char *msg) noexcept;
  15. void logServiceStarted(const char *service_name) noexcept;
  16. void logServiceFailed(const char *service_name) noexcept;
  17. void logServiceStopped(const char *service_name) noexcept;
  18. static inline void log(LogLevel lvl, const std::string &str)
  19. {
  20. log(lvl, str.c_str());
  21. }
  22. static inline void logServiceStarted(const std::string &str)
  23. {
  24. logServiceStarted(str.c_str());
  25. }
  26. static inline void logServiceFailed(const std::string &str)
  27. {
  28. logServiceFailed(str.c_str());
  29. }
  30. static inline void logServiceStopped(const std::string &str)
  31. {
  32. logServiceStopped(str.c_str());
  33. }
  34. #endif