ZCLibLog
载入中...
搜索中...
未找到
cstdio.hpp
浏览该文件的文档.
1// Copyright 2026 CZF-H
2// Licensed under the Apache License, Version 2.0
3
4//
5// Created by wanjiangzhi on 2026/3/30.
6//
7
8#ifndef ZCLIBLOG_EXECUTORS_CSTDOUT_HPP
9#define ZCLIBLOG_EXECUTORS_CSTDOUT_HPP
10
11#include "basic_executor.hpp"
12#include <cstdio>
13
14// NOLINTNEXTLINE
15namespace ZCLibLog {
16 namespace executors {
23 explicit cstdio(const bool enable_fwrite = false) : enable_fwrite(enable_fwrite) {}
24 void do_execute(ELString msg, ELogLevel lv) override {
25 if (enable_fwrite) {
26 if (lv >= LogLevel::ERROR) {
27 fwrite(msg.data(), 1, msg.size(), stderr);
28 fwrite("\n", 1, 1, stderr);
29 } else {
30 fwrite(msg.data(), 1, msg.size(), stdout);
31 fwrite("\n", 1, 1, stdout);
32 }
33 } else {
34 if (lv >= LogLevel::ERROR) {
35 fputs(msg.c_str(), stderr);
36 fputs("\n", stderr);
37 } else {
38 fputs(msg.c_str(), stdout);
39 fputs("\n", stdout);
40 }
41 }
42 }
43 private:
44 const bool enable_fwrite;
45 };
46 }
47}
48
49#endif //ZCLIBLOG_EXECUTORS_CSTDOUT_HPP
ZCLibLog的命名空间
Definition android_log.hpp:16
执行器的基类抽象类
Definition logger_types.hpp:106
ELogLevel ELogLevel
简化写法
Definition logger_types.hpp:116
ELString ELString
简化写法
Definition logger_types.hpp:114
C语言"stdout/stderr"标准输出执行器
Definition cstdio.hpp:22
cstdio(const bool enable_fwrite=false)
Definition cstdio.hpp:23
void do_execute(ELString msg, ELogLevel lv) override
自定义执行器需要重载的执行函数
Definition cstdio.hpp:24