aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/actors/log_backend/actor_log_backend.cpp
blob: a6fdd20c7b459d1005eb35c796b17972d555ac00 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "actor_log_backend.h"

#include <library/cpp/actors/core/actorsystem.h>
#include <library/cpp/actors/core/log.h>
#include <library/cpp/logger/record.h>

namespace {

NActors::NLog::EPriority GetActorLogPriority(ELogPriority priority) {
    switch (priority) {
    case TLOG_EMERG:
        return NActors::NLog::PRI_EMERG;
    case TLOG_ALERT:
        return NActors::NLog::PRI_ALERT;
    case TLOG_CRIT:
        return NActors::NLog::PRI_CRIT;
    case TLOG_ERR:
        return NActors::NLog::PRI_ERROR;
    case TLOG_WARNING:
        return NActors::NLog::PRI_WARN;
    case TLOG_NOTICE:
        return NActors::NLog::PRI_NOTICE;
    case TLOG_INFO:
        return NActors::NLog::PRI_INFO;
    case TLOG_DEBUG:
        return NActors::NLog::PRI_DEBUG;
    default:
        return NActors::NLog::PRI_TRACE;
    }
}

}

TActorLogBackend::TActorLogBackend(NActors::TActorSystem* actorSystem, int logComponent)
    : ActorSystem(actorSystem)
    , LogComponent(logComponent)
{
}

void TActorLogBackend::WriteData(const TLogRecord& rec) {
    LOG_LOG(*ActorSystem, GetActorLogPriority(rec.Priority), LogComponent, TString(rec.Data, rec.Len));
}