aboutsummaryrefslogtreecommitdiffstats
path: root/library/python/deprecated/ticket_parser2/src/logger.h
blob: 9a89f3032429e525f0c14860bfdcc70074e2da00 (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
#pragma once

#include <library/cpp/pybind/ptr.h>
#include <library/cpp/tvmauth/client/logger.h>

extern "C" {
    void cy_call_func(PyObject*, char*, int, const char*, size_t);
}

namespace NTvmAuth {
    class IPyLogger: public ILogger {
    public:
        NPyBind::TPyObjectPtr Obj_;

        IPyLogger(PyObject* obj)
            : Obj_(obj)
        {
        }

        ~IPyLogger() {
        }

        void Log(int lvl, const TString& msg) override {
            if (!Obj_) {
                return;
            }

            cy_call_func(this->Obj_.Get(), (char*)"__log", lvl, msg.data(), msg.size());
        }
    };
}