-
Notifications
You must be signed in to change notification settings - Fork 706
Expand file tree
/
Copy pathlogger.hpp
More file actions
55 lines (44 loc) · 1.13 KB
/
logger.hpp
File metadata and controls
55 lines (44 loc) · 1.13 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once
#include <base/logger.hpp>
#include <base/logger_adapter.hpp>
#include <mutex>
#include <string>
#ifdef __cplusplus
extern "C" {
#endif
#include <utils/elog.h>
#ifdef __cplusplus
} /// extern "C"
#endif
namespace pg {
class logger_adapter : public base::logger_adapter
{
public:
logger_adapter() = default;
~logger_adapter() override = default;
[[nodiscard]] const std::string name() const override
{
return "pg_deeplake";
}
void log(base::log_level level, const std::string& channel, const std::string& message) override
{
std::lock_guard lock(mutex_);
switch (level) {
case base::log_level::debug:
elog(DEBUG1, "%s", message.c_str());
break;
case base::log_level::info:
elog(LOG, "%s", message.c_str());
break;
case base::log_level::warning:
elog(WARNING, "%s", message.c_str());
break;
case base::log_level::error:
elog(NOTICE, "Error from DeepLake: %s", message.c_str());
break;
}
}
private:
std::mutex mutex_;
};
} // namespace pg