MCPcopy Create free account
hub / github.com/Notgnoshi/generative / main

Function main

tests/main.cpp:11–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9static auto s_logger = log4cplus::Logger::getRoot();
10
11int main(int argc, char* argv[])
12{
13 log4cplus::Initializer initializer;
14 // A basic ConsoleAppender that logs to stderr.
15 auto appender = log4cplus::SharedAppenderPtr(new log4cplus::ConsoleAppender(true, true));
16 s_logger.setLogLevel(log4cplus::ERROR_LOG_LEVEL);
17 s_logger.addAppender(appender);
18
19 //! @todo I don't know if I need to initialize both?
20 // testing::InitGoogleTest(&argc, argv);
21 testing::InitGoogleMock(&argc, argv);
22
23 // Sure, this is terrible, but it's also for the tests, and is hopefully not used much.
24 for (int i = 0; i < argc; i++)
25 {
26 const std::string arg(argv[i]);
27 if (arg == "-l" || arg == "--log-level")
28 {
29 i++;
30 if (i >= argc)
31 {
32 LOG4CPLUS_FATAL(s_logger, "--log-level requires an argument");
33 std::exit(1);
34 }
35 const std::string log_level = argv[i];
36 if (log_level == "TRACE")
37 {
38 s_logger.setLogLevel(log4cplus::TRACE_LOG_LEVEL);
39 } else if (log_level == "DEBUG")
40 {
41 s_logger.setLogLevel(log4cplus::DEBUG_LOG_LEVEL);
42 } else if (log_level == "INFO")
43 {
44 s_logger.setLogLevel(log4cplus::INFO_LOG_LEVEL);
45
46 } else if (log_level == "WARN")
47 {
48 s_logger.setLogLevel(log4cplus::WARN_LOG_LEVEL);
49
50 } else if (log_level == "ERROR")
51 {
52 s_logger.setLogLevel(log4cplus::ERROR_LOG_LEVEL);
53
54 } else if (log_level == "FATAL")
55 {
56 s_logger.setLogLevel(log4cplus::FATAL_LOG_LEVEL);
57 } else
58 {
59 LOG4CPLUS_ERROR(s_logger, "Unknown log level '" << log_level << "'");
60 std::exit(1);
61 }
62 }
63 }
64
65 return RUN_ALL_TESTS();
66}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected