dinit-log.cc 839 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include <iostream>
  2. #include "dinit-log.h"
  3. LogLevel log_level = LogLevel::WARN;
  4. bool log_to_console = true; // whether we should output log messages to console
  5. // Log a message
  6. void log(LogLevel lvl, const char *msg) noexcept
  7. {
  8. if (lvl >= log_level) {
  9. if (log_to_console) {
  10. std::cout << "dinit: " << msg << std::endl;
  11. }
  12. }
  13. }
  14. void logServiceStarted(const char *service_name) noexcept
  15. {
  16. if (log_to_console) {
  17. std::cout << "[ OK ] " << service_name << std::endl;
  18. }
  19. }
  20. void logServiceFailed(const char *service_name) noexcept
  21. {
  22. if (log_to_console) {
  23. std::cout << "[FAILED] " << service_name << std::endl;
  24. }
  25. }
  26. void logServiceStopped(const char *service_name) noexcept
  27. {
  28. if (log_to_console) {
  29. std::cout << "[STOPPED] " << service_name << std::endl;
  30. }
  31. }