-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.cc
38 lines (29 loc) · 1.05 KB
/
main.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <glog/logging.h>
#include <filesystem>
auto main(int argc, char **argv) -> int
{
(void) argc;
const auto log_dir = std::filesystem::current_path() / "glog";
// Initialize Google’s logging library.
google::InitGoogleLogging(argv[0]);
google::InstallFailureSignalHandler();
google::SetLogFilenameExtension(".log");
google::EnableLogCleaner(std::chrono::hours(24 * 7));
//google::DisableLogCleaner();
FLAGS_alsologtostderr = true; // 是否将日志输出到文件和stderr
FLAGS_colorlogtostderr = true; // 是否启用不同颜色显示
FLAGS_max_log_size = 1000; // 最大日志文件大小
fLS::FLAGS_log_dir = log_dir.string();
std::filesystem::create_directories(log_dir);
std::string message("Hello World");
LOG(INFO) << message;
LOG(WARNING) << message;
LOG(ERROR) << message;
// LOG(FATAL) << message;
DLOG(INFO) << message;
DLOG(WARNING) << message;
DLOG(ERROR) << message;
// DLOG(FATAL) << message;
google::ShutdownGoogleLogging();
return 0;
}