Add log support and tests

Former-commit-id: f946b994174633082110e8d5b26640998e4ed35e
This commit is contained in:
jinhai 2019-04-14 19:46:25 +08:00
parent 21e95ab5c2
commit 987ff82e10
5 changed files with 46 additions and 15 deletions

View File

@ -0,0 +1,27 @@
* GLOBAL:
FORMAT = "%datetime | %level | %logger | %msg"
FILENAME = "/tmp/logs/vecwise/vecwise_engine-%datetime{%H:%m}-global.log"
ENABLED = true
TO_FILE = true
TO_STANDARD_OUTPUT = true
SUBSECOND_PRECISION = 3
PERFORMANCE_TRACKING = false
MAX_LOG_FILE_SIZE = 2097152 ## Throw log files away after 2MB
* DEBUG:
FILENAME = "/tmp/logs/vecwise/vecwise_engine-%datetime{%H:%m}-debug.log"
ENABLED = true
* WARNING:
FILENAME = "/tmp/logs/vecwise/vecwise_engine-%datetime{%H:%m}-warning.log"
* TRACE:
FILENAME = "/tmp/logs/vecwise/vecwise_engine-%datetime{%H:%m}-trace.log"
* VERBOSE:
FORMAT = "%datetime{%d/%M/%y} | %level-%vlevel | %msg"
TO_FILE = false
TO_STANDARD_OUTPUT = true
## Error logs
* ERROR:
ENABLED = false
FILENAME = "/tmp/logs/vecwise/vecwise_engine-%datetime{%H:%m}-error.log"
* FATAL:
ENABLED = false
FILENAME = "/tmp/logs/vecwise/vecwise_engine-%datetime{%H:%m}-fatal.log"

View File

@ -4,10 +4,10 @@
# Proprietary and confidential. # Proprietary and confidential.
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
aux_source_directory(./cache cache_files) aux_source_directory(cache cache_files)
aux_source_directory(./config config_files) aux_source_directory(config config_files)
aux_source_directory(./server server_files) aux_source_directory(server server_files)
aux_source_directory(./utils utils_files) aux_source_directory(utils utils_files)
set(vecwise_engine_src set(vecwise_engine_src
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp

View File

@ -9,7 +9,7 @@ link_directories(
) )
set(unittest_srcs set(unittest_srcs
${CMAKE_CURRENT_SOURCE_DIR}/vecwise_test.cpp) ${CMAKE_CURRENT_SOURCE_DIR}/vecwise_test.cpp ${VECWISE_THIRD_PARTY_BUILD}/include/easylogging++.cc)
set(unittest_libs set(unittest_libs
gtest_main gtest_main

View File

@ -4,16 +4,17 @@
// Proprietary and confidential. // Proprietary and confidential.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "easylogging++.h"
class LogTest: public testing::Test {
protected:
void SetUp() override {
el::Configurations conf("../../../conf/vecwise_engine_log.conf");
el::Loggers::reconfigureAllLoggers(conf);
}
};
TEST(LogTest, INIT_TEST) { TEST_F(LogTest, TEST) {
ASSERT_STREQ("A", "A"); EXPECT_FALSE(el::Loggers::hasFlag(el::LoggingFlag::NewLineForContainer));
} EXPECT_FALSE(el::Loggers::hasFlag(el::LoggingFlag::LogDetailedCrashReason));
TEST(LogTest, RUN_TEST) {
ASSERT_STREQ("B", "B");
}
TEST(LogTest, FINISH_TEST) {
ASSERT_STREQ("C", "C");
} }

View File

@ -5,6 +5,9 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include <easylogging++.h>
INITIALIZE_EASYLOGGINGPP
int main(int argc, char **argv) { int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);