模板集合
clang-doc 文档
博客
AirlineTicket
1.0.12
Toggle main menu visibility
Loading...
Searching...
No Matches
ScenarioLog.hxx
Go to the documentation of this file.
1
#pragma once
2
11
12
#ifndef CXX_LOG_DIR
13
#define CXX_LOG_DIR "log"
14
#endif
15
16
// 每个 log 文件最多保留的行数(改这里;重新编译 + cmake .. 后生效)
17
// 提示:cmake_configure.log 镜像全部终端 STATUS,完整一次配置约 150+ 行
18
#ifndef CXX_LOG_MAX_LINES
19
#define CXX_LOG_MAX_LINES 300
20
#endif
21
22
#include <spdlog/spdlog.h>
23
24
#include <string>
25
#include <string_view>
26
27
namespace
scenario_log
{
28
30
void
trim_log_file
(
const
std::string& path);
31
33
bool
under_lldb
();
34
36
spdlog::logger&
exe_logger
();
37
39
void
log_info
(std::string_view msg);
40
42
void
log_error
(std::string_view msg);
43
45
void
log_sep
();
46
48
spdlog::logger&
gtest_logger
();
49
51
void
gtest_info
(std::string_view msg);
52
54
template
<
typename
In,
typename
Out>
55
void
gtest_case
(std::string_view fn,
const
In& input,
const
Out& expected,
const
Out& actual) {
56
gtest_logger
().info(
" {} input={} expected={} actual={}"
, fn, input, expected, actual);
57
trim_log_file
(std::string(
CXX_LOG_DIR
) +
"/gtest.log"
);
58
}
59
60
}
// namespace scenario_log
log_info
void log_info(std::string_view msg)
写 INFO 级日志并触发裁剪
Definition
ScenarioLog.cxx:85
log_sep
void log_sep()
输出分隔线(经 log_info)
Definition
ScenarioLog.cxx:97
CXX_LOG_DIR
#define CXX_LOG_DIR
Definition
ScenarioLog.hxx:13
gtest_info
void gtest_info(std::string_view msg)
GTest 用 INFO 日志并裁剪 gtest.log.
Definition
ScenarioLog.cxx:118
scenario_log
Definition
ScenarioLog.cxx:22
scenario_log::log_error
void log_error(std::string_view msg)
写 ERROR 级日志并触发裁剪
Definition
ScenarioLog.cxx:91
scenario_log::gtest_case
void gtest_case(std::string_view fn, const In &input, const Out &expected, const Out &actual)
终端 / gtest.log:记录函数名、输入、预期、实际
Definition
ScenarioLog.hxx:55
scenario_log::under_lldb
bool under_lldb()
CXX_LLDB 非空且非 "0",或 macOS 上进程被 tracer 附加
Definition
ScenarioLog.cxx:51
scenario_log::trim_log_file
void trim_log_file(const std::string &path)
读入全文后只保留末尾 CXX_LOG_MAX_LINES 行,防止 log 无限增长
Definition
ScenarioLog.cxx:30
scenario_log::exe_logger
spdlog::logger & exe_logger()
懒初始化:LLDB 下写 lldb_debug.log,否则 exe.log
Definition
ScenarioLog.cxx:67
scenario_log::gtest_logger
spdlog::logger & gtest_logger()
GTest 专用 logger,文件名固定 gtest.log.
Definition
ScenarioLog.cxx:102
CXX-CMake-template
CXX-CMake-template
single-exe-modules
src
ScenarioLog.hxx
Generated by
1.18.0