-};
-
-class LogCore {
- public:
- // Do not call this function at destructor of global object
- static LogCore& GetCore() {
- static LogCore core;
- return core;
- }
-
- void AddLogBackend(std::shared_ptr<ILogBackend> backend) {
- backend_list_.emplace_back(backend);
- }
-
- void Log(LogLevel level, const std::string& tag, const std::string& log) {
- for (auto& backend : backend_list_)
- backend->WriteLog(level, tag, log);
- }
-
- private:
- LogCore() {
- // add default dlog backend
- AddLogBackend(std::shared_ptr<ILogBackend>(new DLogBackend()));
- }
- ~LogCore() = default;
- LogCore(const LogCore&) = delete;
- LogCore& operator=(const LogCore&) = delete;
-
- std::vector<std::shared_ptr<ILogBackend>> backend_list_;
-};
-
-class LogCatcher {
- public:
- LogCatcher(LogLevel level, const char* tag)
- : level_(level), tag_(tag) { }
-
- void operator&(const StringStream<char>& str) const {
- LogCore::GetCore().Log(level_, tag_, str.str());
- }
-
- private: