5#ifndef ZCLIBLOG_LOGGER_TYPES_HPP
6#define ZCLIBLOG_LOGGER_TYPES_HPP
24 #define ZCLIBLOG_HELPER_LEVELS(Register) \
32 Register(OFF, std::numeric_limits<LogLevelBase>::max())
36 #define ZCLIBLOG_HELPER_ENUM_CASE(name, value) name = value,
38 #undef ZCLIBLOG_HELPER_ENUM_CASE
48 #define ZCLIBLOG_HELPER_ENUM_CASE(name, value) case LogLevel::name: return #name;
50 #undef ZCLIBLOG_HELPER_ENUM_CASE
55 #undef ZCLIBLOG_HELPER_LEVELS
63 const std::string*
name = {};
126 template <
typename Executor>
165 made.executor_ptr = std::move(std::make_shared<Executor>(std::forward<Args>(
args)...));
167 return std::move(
made);
172 return executor_ptr.
get();
190 return executor_ptr.operator->();
195 return executor_ptr.operator*();
201 return executor_ptr.
get() !=
nullptr;
230 template <
typename FormatAPI>
232 : std::integral_constant<
234 std::is_base_of<format_api, FormatAPI>::value &&
235 !std::is_same<FormatAPI, format_api>::value
244 template <
typename Formatter>
246 : std::integral_constant<
248 std::is_base_of<format_api, typename Formatter::Format_API>::value &&
249 !std::is_same<typename Formatter::Format_API, format_api>::value &&
250 std::is_base_of<typename Formatter::Format_API, Formatter>::value &&
251 !std::is_same<typename Formatter::Format_API, Formatter>::value
259 template <
typename Logger>
264 const auto now = std::chrono::system_clock::now();
265 const auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
266 now.time_since_epoch()
310 template <
typename FormatterAPI,
typename Logger>
315 "Formatter must be format_api"
根基Tag类,构造无用,仅继承
Definition logger_types.hpp:260
LogTagBase(const Logger *const logger, const LogLevel level)
构造Tag
Definition logger_types.hpp:300
ZCLibLog_NODISCARD const LogLevel & level() const noexcept
获取当前Tag的等级
Definition logger_types.hpp:291
ZCLibLog_NODISCARD bool check_executable() const
检查是否可执行
Definition logger_types.hpp:278
ZCLibLog_NODISCARD LogPack get_log_pack() const
获取当前的日志信息包
Definition logger_types.hpp:263
const LogLevel m_level
Definition logger_types.hpp:288
const Logger *const m_logger
Definition logger_types.hpp:287
执行器包装类
Definition logger_types.hpp:133
std::shared_ptr< executor_api > base_ptr_type
Definition logger_types.hpp:135
static executor make(Args &&... args)
通过工厂函数构造
Definition logger_types.hpp:161
base_ptr_type::element_type inside_type
Definition logger_types.hpp:136
inside_type & operator*() const noexcept
获取内部执行器对象
Definition logger_types.hpp:194
ZCLibLog_NODISCARD bool unique() const noexcept
获取执行器是否独占状态
Definition logger_types.hpp:176
inside_type * operator->() const noexcept
访问内部执行器内部成员
Definition logger_types.hpp:189
executor(inside_type *executor_ptr)
通过裸指针构造
Definition logger_types.hpp:151
ZCLibLog_NODISCARD long use_count() const noexcept
获取执行器使用计数
Definition logger_types.hpp:184
ZCLibLog_NODISCARD inside_type * get() const noexcept
获取内部执行器的指针
Definition logger_types.hpp:171
#define ZCLibLog_NODISCARD
Definition logger_macros.h:50
#define ZCLIBLOG_HELPER_LEVELS(Register)
注册日志等级
Definition logger_types.hpp:24
ZCLibLog的命名空间
Definition android_log.hpp:16
std::is_base_of< executor_api, Executor > is_executor_api
判断是否是基于executor api
Definition logger_types.hpp:127
uint16_t LogLevelBase
日志等级的基础类型
Definition logger_types.hpp:18
const std::string & ELString
执行器接受的字符串
Definition logger_types.hpp:100
std::string FLString
格格式化输出的字符串
Definition logger_types.hpp:208
LogLevel
一些日志等级
Definition logger_types.hpp:35
ZCLIBLOG_HELPER_ENUM_CASE(name, value)
const char * LogLevelToString(const LogLevel level)
获取日志等级的文本字符串
Definition logger_types.hpp:46
Log等级范围
Definition logger_types.hpp:74
LogLevel max_level
配置的最高等级
Definition logger_types.hpp:78
LogLevelCfg(const LogLevel min_level, const LogLevel max_level)
等级范围构造
Definition logger_types.hpp:93
LogLevelCfg(const LogLevel level={})
单等级构造
Definition logger_types.hpp:85
LogLevel min_level
配置的最低等级
Definition logger_types.hpp:76
Log格式化的参数包
Definition logger_types.hpp:61
const std::string * name
该日志的名字
Definition logger_types.hpp:63
uint64_t time
该日志的时间戳
Definition logger_types.hpp:65
LogLevel level
该日志的级别
Definition logger_types.hpp:67
泛型模板,无法特化
Definition logger_types.hpp:311
执行器的基类抽象类
Definition logger_types.hpp:106
LogLevel LogLevel
简化写法
Definition logger_types.hpp:118
virtual ~executor_api()=default
自定义执行器可能重载的析构函数
virtual void do_execute(ELString, ELogLevel)=0
自定义执行器需要重载的执行函数
ELogLevel ELogLevel
简化写法
Definition logger_types.hpp:116
ELString ELString
简化写法
Definition logger_types.hpp:114