summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xveslibrary/ves_cpplibrary/src/CMakeLists.txt15
-rw-r--r--veslibrary/ves_cpplibrary/src/Makefile20
-rw-r--r--veslibrary/ves_cpplibrary/src/cmake/leveldbConfig.cmake5
-rw-r--r--veslibrary/ves_cpplibrary/src/cmake/thriftConfig.cmake5
-rw-r--r--veslibrary/ves_cpplibrary/src/cmake/xencodeConfig.cmake6
-rw-r--r--veslibrary/ves_cpplibrary/src/cmake/xlogConfig.cmake4
-rw-r--r--veslibrary/ves_cpplibrary/src/cmake/xtransportConfig.cmake6
-rwxr-xr-xveslibrary/ves_cpplibrary/src/lib/CMakeLists.txt12
-rwxr-xr-xveslibrary/ves_cpplibrary/src/lib/common/XLog.cpp25
-rwxr-xr-xveslibrary/ves_cpplibrary/src/lib/common/XLog.h35
10 files changed, 133 insertions, 0 deletions
diff --git a/veslibrary/ves_cpplibrary/src/CMakeLists.txt b/veslibrary/ves_cpplibrary/src/CMakeLists.txt
new file mode 100755
index 0000000..b788dab
--- /dev/null
+++ b/veslibrary/ves_cpplibrary/src/CMakeLists.txt
@@ -0,0 +1,15 @@
+cmake_minimum_required (VERSION 2.8)
+
+project (xvesagent)
+
+set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+
+OPTION (ENABLE_COVERAGE "Use gcov" OFF)
+MESSAGE(STATUS ENABLE_COVERAGE=${ENABLE_COVERAGE})
+IF(ENABLE_COVERAGE)
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
+ENDIF()
+
+add_subdirectory(lib)
diff --git a/veslibrary/ves_cpplibrary/src/Makefile b/veslibrary/ves_cpplibrary/src/Makefile
new file mode 100644
index 0000000..b0bc5eb
--- /dev/null
+++ b/veslibrary/ves_cpplibrary/src/Makefile
@@ -0,0 +1,20 @@
+all:
+ mkdir build
+ cd build; cmake ..; make; make install
+
+.PHONY : test
+test:
+ mkdir build
+ cd build; cmake .. -DENABLE_COVERAGE=ON; make; make install
+ mkdir test/build
+ cd test/build; cmake .. -DENABLE_COVERAGE=ON; make; ./xtest
+ lcov -c -d build/lib/encode/CMakeFiles/xencode.dir -d build/lib/transport/CMakeFiles/xtransport.dir -o coverage.info
+ lcov -r coverage.info '/usr/*' '*/transport/gen-cpp/*' -o xvesagent.info
+ genhtml xvesagent.info -o coverage
+ rm -rf *.info
+
+clean:
+ rm *.info -rf
+ rm build -rf
+ rm coverage -rf
+ rm test/build -rf
diff --git a/veslibrary/ves_cpplibrary/src/cmake/leveldbConfig.cmake b/veslibrary/ves_cpplibrary/src/cmake/leveldbConfig.cmake
new file mode 100644
index 0000000..63bae3c
--- /dev/null
+++ b/veslibrary/ves_cpplibrary/src/cmake/leveldbConfig.cmake
@@ -0,0 +1,5 @@
+find_library(LEVELDB_LIBRARY libleveldb.a)
+find_path(LEVELDB_INCLUDE_DIR leveldb/db.h)
+message("leveldb include dir: ${LEVELDB_INCLUDE_DIR}")
+message("leveldb library dir: ${LEVELDB_LIBRARY}")
+
diff --git a/veslibrary/ves_cpplibrary/src/cmake/thriftConfig.cmake b/veslibrary/ves_cpplibrary/src/cmake/thriftConfig.cmake
new file mode 100644
index 0000000..0c0bb5f
--- /dev/null
+++ b/veslibrary/ves_cpplibrary/src/cmake/thriftConfig.cmake
@@ -0,0 +1,5 @@
+find_library(THRIFT_LIBRARY libthrift.a)
+find_path(THRIFT_INCLUDE_DIR thrift/Thrift.h)
+message("thrift include dir: ${THRIFT_INCLUDE_DIR}")
+message("thrift library dir: ${THRIFT_LIBRARY}")
+
diff --git a/veslibrary/ves_cpplibrary/src/cmake/xencodeConfig.cmake b/veslibrary/ves_cpplibrary/src/cmake/xencodeConfig.cmake
new file mode 100644
index 0000000..2c8c993
--- /dev/null
+++ b/veslibrary/ves_cpplibrary/src/cmake/xencodeConfig.cmake
@@ -0,0 +1,6 @@
+find_library(XENCODE_LIBRARY xencode)
+find_path(XENCODE_INCLUDE_DIR xvesagent/xencode/XEvent.h)
+set(XENCODE_INCLUDE_DIR "${XENCODE_INCLUDE_DIR}/xvesagent/xencode")
+message("xencode include dir: ${XENCODE_INCLUDE_DIR}")
+message("xencode library dir: ${XENCODE_LIBRARY}")
+
diff --git a/veslibrary/ves_cpplibrary/src/cmake/xlogConfig.cmake b/veslibrary/ves_cpplibrary/src/cmake/xlogConfig.cmake
new file mode 100644
index 0000000..819279f
--- /dev/null
+++ b/veslibrary/ves_cpplibrary/src/cmake/xlogConfig.cmake
@@ -0,0 +1,4 @@
+find_path(XLOG_INCLUDE_DIR xvesagent/XLog.h)
+set(XLOG_INCLUDE_DIR "${XLOG_INCLUDE_DIR}/xvesagent")
+message("xlog include dir: ${XLOG_INCLUDE_DIR}")
+
diff --git a/veslibrary/ves_cpplibrary/src/cmake/xtransportConfig.cmake b/veslibrary/ves_cpplibrary/src/cmake/xtransportConfig.cmake
new file mode 100644
index 0000000..f0163eb
--- /dev/null
+++ b/veslibrary/ves_cpplibrary/src/cmake/xtransportConfig.cmake
@@ -0,0 +1,6 @@
+find_library(XTRANSPORT_LIBRARY xtransport)
+find_path(XTRANSPORT_INCLUDE_DIR xvesagent/xtransport/XTransport.h)
+set(XTRANSPORT_INCLUDE_DIR "${XTRANSPORT_INCLUDE_DIR}/xvesagent/xtransport")
+message("xtransport include dir: ${XTRANSPORT_INCLUDE_DIR}")
+message("xtransport library dir: ${XTRANSPORT_LIBRARY}")
+
diff --git a/veslibrary/ves_cpplibrary/src/lib/CMakeLists.txt b/veslibrary/ves_cpplibrary/src/lib/CMakeLists.txt
new file mode 100755
index 0000000..51f59d1
--- /dev/null
+++ b/veslibrary/ves_cpplibrary/src/lib/CMakeLists.txt
@@ -0,0 +1,12 @@
+add_subdirectory(encode)
+add_subdirectory(transport)
+
+file(GLOB COM_HDRS "common/*.h")
+
+install(FILES ${COM_HDRS}
+ DESTINATION "include/xvesagent"
+)
+
+install(FILES ../cmake/xlogConfig.cmake
+ DESTINATION "lib/cmake/xlog"
+)
diff --git a/veslibrary/ves_cpplibrary/src/lib/common/XLog.cpp b/veslibrary/ves_cpplibrary/src/lib/common/XLog.cpp
new file mode 100755
index 0000000..ba628b9
--- /dev/null
+++ b/veslibrary/ves_cpplibrary/src/lib/common/XLog.cpp
@@ -0,0 +1,25 @@
+#include "XLog.h"
+#include "spdlog/spdlog.h"
+#include "spdlog/sinks/rotating_file_sink.h"
+#include "spdlog/sinks/stdout_color_sinks.h"
+
+void vagt::log::init(const std::string& path, int logFileSize, int logFileNum)
+{
+ auto logger = spdlog::rotating_logger_mt("xvagt", path, logFileSize, logFileNum);
+ spdlog::set_default_logger(logger);
+ spdlog::default_logger()->set_pattern("%^%L%$ [%Y-%m-%d %H:%M:%S.%e][%t][%@] %v");
+ spdlog::default_logger()->flush_on(spdlog::level::info);
+ spdlog::default_logger()->set_level(spdlog::level::info);
+ /*
+ spdlog::default_logger()->set_pattern("%^%L%$ [%Y-%m-%d %H:%M:%S.%e][%t][%@] %v");
+ spdlog::flush_on(spdlog::level::info);
+ spdlog::set_level(spdlog::level::info);
+ */
+}
+
+void vagt::log::setLevel(vagt::log::XLogLevel level)
+{
+ spdlog::default_logger()->set_level(spdlog::level::level_enum(level));
+ spdlog::default_logger()->flush_on(spdlog::level::level_enum(level));
+}
+
diff --git a/veslibrary/ves_cpplibrary/src/lib/common/XLog.h b/veslibrary/ves_cpplibrary/src/lib/common/XLog.h
new file mode 100755
index 0000000..aae8c31
--- /dev/null
+++ b/veslibrary/ves_cpplibrary/src/lib/common/XLog.h
@@ -0,0 +1,35 @@
+#pragma once
+
+#include <string>
+
+namespace vagt
+{
+ namespace log
+ {
+ /*************************************************************************************************//**
+ * @brief Log level
+ *****************************************************************************************************/
+ enum XLogLevel
+ {
+ XLogTrace,
+ XLogDebug,
+ XLogInfo,
+ XLogWarn,
+ XLogErr,
+ XLogCritical,
+ XLogOff,
+ };
+
+ /*************************************************************************************************//**
+ * Initialize the file logging.
+ *
+ * @note To disable logging, set the path to "/dev/null" .
+ *****************************************************************************************************/
+ void init(const std::string& path, int logFileSize = 1048576 * 5, int logFileNum = 10);
+
+ /*************************************************************************************************//**
+ * Set log level.
+ *****************************************************************************************************/
+ void setLevel(XLogLevel level);
+ }
+}