提交 2f1e8218fdb53605f4739015939e4ff18d259eef

作者 LJH 李佳桓
1 个父辈 f5d06ab1

add

正在显示 1 个修改的文件 包含 83 行增加0 行删除
  1 +/**************************************************************************
  2 +* file: dmplogger.h
  3 +
  4 +* Author: wanzhongping
  5 +* Date: 2021-03-03 10:10:39
  6 +* Email: zhongpingw@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +
  10 +#ifndef __dmplogger_h__
  11 +#define __dmplogger_h__
  12 +
  13 +#include "dmap_core.h"
  14 +#include <string>
  15 +#include <iostream>
  16 +#include <boost/log/attributes/named_scope.hpp>
  17 +
  18 +// Here we define our application severity levels.
  19 +enum SeverityLevel
  20 +{
  21 + debug_level = 0,
  22 + info_level,
  23 + warn_level,
  24 + error_level,
  25 + critical_level
  26 +};
  27 +
  28 +class CORE_EXPORT DmpLogger
  29 +{
  30 +public:
  31 + void Debug(const std::string &msg);
  32 + void Info(const std::string &msg);
  33 + void Warn(const std::string &msg);
  34 + void Error(const std::string &msg);
  35 + void Critical(const std::string &msg);
  36 + void SetLevel(SeverityLevel level);
  37 +
  38 + static DmpLogger *Instance();
  39 +
  40 +private:
  41 + DmpLogger();
  42 + ~DmpLogger();
  43 + DmpLogger(const DmpLogger& other) = delete;
  44 + DmpLogger& operator=(const DmpLogger &other) = delete;
  45 + void Init();
  46 +};
  47 +
  48 +//对外接口宏
  49 +#define LOGGER_DEBUG(msg) \
  50 + \
  51 + { \
  52 + BOOST_LOG_FUNCTION(); \
  53 + DmpLogger::Instance()->Debug(msg); \
  54 + }
  55 +
  56 +#define LOGGER_INFO(msg) \
  57 + \
  58 + { \
  59 + BOOST_LOG_FUNCTION(); \
  60 + DmpLogger::Instance()->Info(msg); \
  61 + }
  62 +
  63 +#define LOGGER_WARN(msg) \
  64 + \
  65 + { \
  66 + BOOST_LOG_FUNCTION(); \
  67 + DmpLogger::Instance()->Warn(msg); \
  68 + }
  69 +
  70 +#define LOGGER_ERROR(msg) \
  71 + \
  72 + { \
  73 + BOOST_LOG_FUNCTION(); \
  74 + DmpLogger::Instance()->Error(msg); \
  75 + }
  76 +
  77 +#define LOGGER_CRITICAL(msg) \
  78 + \
  79 + { \
  80 + BOOST_LOG_FUNCTION(); \
  81 + DmpLogger::Instance()->Critical(msg); \
  82 + }
  83 +#endif //__dmplogger_h__
... ...
注册登录 后发表评论