MCPcopy Create free account
hub / github.com/baidu/babylon / BabylonLogSink

Class BabylonLogSink

example/use-with-glog/example.cpp:6–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4#include "glog/logging.h"
5
6class BabylonLogSink : public ::google::LogSink {
7 public:
8 virtual void send(::google::LogSeverity glog_severity,
9 const char* full_filename, const char*, int line,
10 const ::google::LogMessageTime&, const char* message,
11 size_t message_len) noexcept override {
12 // severity mapping
13 static ::babylon::LogSeverity mapping[] = {
14 [::google::INFO] = ::babylon::LogSeverity::INFO,
15 [::google::WARNING] = ::babylon::LogSeverity::WARNING,
16 [::google::ERROR] = ::babylon::LogSeverity::FATAL,
17 [::google::FATAL] = ::babylon::LogSeverity::FATAL,
18 };
19
20 // root logger severity pre-check
21 auto severity = mapping[glog_severity];
22 auto& logger = ::babylon::LoggerManager::instance().get_root_logger();
23 if (logger.min_severity() > severity) {
24 return;
25 }
26
27 // write to root logger
28 auto& stream = logger.stream(severity, full_filename, line, "");
29 stream.begin();
30 stream.write(message, message_len);
31 stream.end();
32 }
33};
34
35class GLogStream : public ::babylon::LogStream {
36 public:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected