13 #define USE_SPDLOG_FOR_LOGGING 1 17 #ifdef USE_BOOST_LOG_FOR_LOGGING 18 #include <boost/log/core.hpp> 19 #include <boost/log/trivial.hpp> 20 #include <boost/log/expressions.hpp> 23 #ifdef USE_SPDLOG_FOR_LOGGING 24 #include <spdlog/spdlog.h> 27 #ifdef USE_STDOUT_FOR_LOGGING 71 #ifdef USE_BOOST_LOG_FOR_LOGGING 72 #define HKU_DEBUG(msg) if (get_log_level() <= LOG_LEVEL::DEBUG) {\ 73 BOOST_LOG_TRIVIAL(debug) << msg; } 74 #define HKU_TRACE(msg) if (get_log_level() <= LOG_LEVEL::TRACE) {\ 75 BOOST_LOG_TRIVIAL(trace) << msg; } 76 #define HKU_INFO(msg) if (get_log_level() <= LOG_LEVEL::INFO) {\ 77 BOOST_LOG_TRIVIAL(info) << msg; } 78 #define HKU_WARN(msg) if (get_log_level() <= LOG_LEVEL::WARN) {\ 79 BOOST_LOG_TRIVIAL(warning) << msg; } 80 #define HKU_ERROR(msg) if (get_log_level() <= LOG_LEVEL::ERROR) {\ 81 BOOST_LOG_TRIVIAL(error) << msg; } 82 #define HKU_FATAL(msg) if (get_log_level() <= LOG_LEVEL::FATAL) {\ 83 BOOST_LOG_TRIVIAL(fatal) << msg; } 92 #ifdef USE_SPDLOG_FOR_LOGGING 93 #define HKU_DEBUG(msg) if (get_log_level() <= LOG_LEVEL::DEBUG) {\ 94 std::stringstream buf (std::stringstream::out); \ 96 spdlog::get("hikyuu")->debug(buf.str().c_str());} 97 #define HKU_TRACE(msg) if (get_log_level() <= LOG_LEVEL::TRACE){\ 98 std::stringstream buf (std::stringstream::out); \ 100 spdlog::get("hikyuu")->trace(buf.str().c_str());} 101 #define HKU_INFO(msg) if (get_log_level() <= LOG_LEVEL::INFO) {\ 102 std::stringstream buf (std::stringstream::out); \ 104 spdlog::get("hikyuu")->info(buf.str().c_str());} 105 #define HKU_WARN(msg) if (get_log_level() <= LOG_LEVEL::WARN) {\ 106 std::stringstream buf (std::stringstream::out); \ 108 spdlog::get("hikyuu")->warn(buf.str().c_str());} 109 #define HKU_ERROR(msg) if (get_log_level() <= LOG_LEVEL::ERROR) {\ 110 std::stringstream buf (std::stringstream::out); \ 112 spdlog::get("hikyuu")->error(buf.str().c_str());} 113 #define HKU_FATAL(msg) if (get_log_level() <= LOG_LEVEL::FATAL) {\ 114 std::stringstream buf (std::stringstream::out); \ 116 spdlog::get("hikyuu")->critical(buf.str().c_str());} 124 #ifdef USE_STDOUT_FOR_LOGGING 125 #define HKU_DEBUG(msg) if (get_log_level() <= LOG_LEVEL::DEBUG) {\ 126 std::stringstream buf (std::stringstream::out);\ 127 buf << Datetime::now() << " [DEBUG] " << msg;\ 128 std::cout << buf.str() << std::endl} 129 #define HKU_TRACE(msg) if (get_log_level() <= LOG_LEVEL::TRACE) {\ 130 std::stringstream buf (std::stringstream::out);\ 131 buf << Datetime::now() << " [TRACE] " << msg;\ 132 std::cout << buf.str() << std::endl;} 133 #define HKU_INFO(msg) if (get_log_level() <= LOG_LEVEL::INFO) {\ 134 std::stringstream buf (std::stringstream::out);\ 135 buf << Datetime::now() << " [INFO] " << msg;\ 136 std::cout << buf.str() << std::endl;} 137 #define HKU_WARN(msg) if (get_log_level() <= LOG_LEVEL::WARN) {\ 138 std::stringstream buf (std::stringstream::out);\ 139 buf << Datetime::now() << " [WARN] " << msg;\ 140 std::cout << buf.str() << std::endl;} 141 #define HKU_ERROR(msg) if (get_log_level() <= LOG_LEVEL::ERROR) {\ 142 std::stringstream buf (std::stringstream::out);\ 143 buf << Datetime::now() << " [ERROR] " << msg;\ 144 std::cout << buf.str() << std::endl;} 145 #define HKU_FATAL(msg) if (get_log_level() <= LOG_LEVEL::FATAL) {\ 146 std::stringstream buf (std::stringstream::out);\ 147 buf << Datetime::now() << " [FATAL] " << msg;\ 148 std::cout << buf.str() << std::endl;}
std::string string
Definition: DataType.h:55
void set_log_level(LOG_LEVEL level)
设置日志级别
Definition: Log.cpp:29
LOG_LEVEL
Definition: Log.h:37
#define HKU_API
Definition: Log.h:32
LOG_LEVEL get_log_level()
获取当前日志级别
Definition: Log.cpp:25
void init_logger(const std::string &configure_name)
初始化 LOGGER
Definition: Log.cpp:51
Hikyuu核心命名空间,包含股票数据的管理、指标实现、交易系统框架等
Definition: Block.cpp:11