72 lines
1.6 KiB
C++
72 lines
1.6 KiB
C++
#pragma once
|
||
/**
|
||
* @file eqpalg/gb_logger.h
|
||
* @brief eqpalg下的全局logger
|
||
* @author Cat (null.null.null@qq.com)
|
||
* @version 0.1
|
||
* @date 2021-07-08
|
||
* 全局logger,把log信息打印到指定的日志中
|
||
* Company: Baosight Co. Ltd.
|
||
* DO NOT COPY/USE WITHOUT PERMISSION
|
||
*
|
||
*/
|
||
#include <log4cplus/LOG.h>
|
||
#include <boost/assert/source_location.hpp>
|
||
#include <exception>
|
||
#include <filesystem>
|
||
#include <fstream>
|
||
#include <memory>
|
||
#include <string>
|
||
|
||
/**
|
||
* @brief 全局Logger,负载打印Log
|
||
*/
|
||
class GbLogger {
|
||
private:
|
||
std::unique_ptr<LOG> gb_logger_; // 全局logger
|
||
std::unique_ptr<LOG> local_logger_; // 本地logger
|
||
|
||
std::string rule_id_; ///<规则id
|
||
std::string rule_name_; ///<规则名
|
||
|
||
public:
|
||
/**
|
||
* @brief Construct a new Global Logger object
|
||
* @param prefix 自定义的logger前缀
|
||
*/
|
||
GbLogger(std::string prefix);
|
||
/**
|
||
* @brief Construct a new Global Logger object
|
||
* @param ruleId 算法id
|
||
* @param rule_name 算法名
|
||
* 前缀是两者的加和
|
||
*/
|
||
GbLogger(std::string ruleId, std::string rule_name);
|
||
~GbLogger();
|
||
|
||
/**
|
||
* @brief 打印异常的方法,输出到ERROR
|
||
* @param e 捕获的异常
|
||
* @return int
|
||
*/
|
||
int log_exception(const std::exception& e);
|
||
|
||
/**
|
||
* @brief 输出信息到ERROR
|
||
* @return int
|
||
*/
|
||
int log_error(std::string&&);
|
||
int log_error(const std::string&);
|
||
/**
|
||
* @brief 打印信息到本地的INFO
|
||
* @return int
|
||
*/
|
||
int log_info_local_thread(std::string&&);
|
||
|
||
/**
|
||
* @brief 打印信息到全局的INFO
|
||
* @return int
|
||
*/
|
||
int log_info(std::string&&);
|
||
};
|