actor_log_backend.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "actor_log_backend.h"
  2. #include <library/cpp/actors/core/actorsystem.h>
  3. #include <library/cpp/actors/core/log.h>
  4. #include <library/cpp/logger/record.h>
  5. namespace {
  6. NActors::NLog::EPriority GetActorLogPriority(ELogPriority priority) {
  7. switch (priority) {
  8. case TLOG_EMERG:
  9. return NActors::NLog::PRI_EMERG;
  10. case TLOG_ALERT:
  11. return NActors::NLog::PRI_ALERT;
  12. case TLOG_CRIT:
  13. return NActors::NLog::PRI_CRIT;
  14. case TLOG_ERR:
  15. return NActors::NLog::PRI_ERROR;
  16. case TLOG_WARNING:
  17. return NActors::NLog::PRI_WARN;
  18. case TLOG_NOTICE:
  19. return NActors::NLog::PRI_NOTICE;
  20. case TLOG_INFO:
  21. return NActors::NLog::PRI_INFO;
  22. case TLOG_DEBUG:
  23. return NActors::NLog::PRI_DEBUG;
  24. default:
  25. return NActors::NLog::PRI_TRACE;
  26. }
  27. }
  28. }
  29. TActorLogBackend::TActorLogBackend(NActors::TActorSystem* actorSystem, int logComponent)
  30. : ActorSystem(actorSystem)
  31. , LogComponent(logComponent)
  32. {
  33. }
  34. void TActorLogBackend::WriteData(const TLogRecord& rec) {
  35. LOG_LOG(*ActorSystem, GetActorLogPriority(rec.Priority), LogComponent, TString(rec.Data, rec.Len));
  36. }