Skip to content

Commit cdacbcd

Browse files
committed
Added static function WsjcppLog::setRotationPeriodInSec
1 parent 375fbc0 commit cdacbcd

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

src.wsjcpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Automaticly generated by [email protected]
22
cmake_minimum_required(VERSION 3.0)
33

4-
add_definitions(-DWSJCPP_VERSION="v0.1.3")
4+
add_definitions(-DWSJCPP_VERSION="v0.1.4")
55
add_definitions(-DWSJCPP_NAME="wsjcpp-core")
66

77
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

src/wsjcpp_core.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,12 +644,13 @@ std::string WsjcppLog::g_WSJCPP_LOG_DIR = "./";
644644
std::string WsjcppLog::g_WSJCPP_LOG_FILE = "";
645645
std::string WsjcppLog::g_WSJCPP_LOG_PREFIX_FILE = "";
646646
long WsjcppLog::g_WSJCPP_LOG_START_TIME = 0;
647+
long WsjcppLog::g_WSJCPP_LOG_ROTATION_PERIOD_IN_SECONDS = 51000;
647648

648649
// ---------------------------------------------------------------------
649650

650651
void WsjcppLog::doLogRotateUpdateFilename(bool bForce) {
651652
long t = WsjcppCore::currentTime_seconds();
652-
long nEverySeconds = 51000; // rotate log if started now or if time left more then 1 day
653+
long nEverySeconds = WsjcppLog::g_WSJCPP_LOG_ROTATION_PERIOD_IN_SECONDS; // rotate log if started now or if time left more then 1 day
653654
if (g_WSJCPP_LOG_START_TIME == 0 || t - g_WSJCPP_LOG_START_TIME > nEverySeconds || bForce) {
654655
g_WSJCPP_LOG_START_TIME = t;
655656
g_WSJCPP_LOG_FILE = g_WSJCPP_LOG_DIR + "/"
@@ -722,6 +723,13 @@ void WsjcppLog::setPrefixLogFile(const std::string &sPrefixLogFile) {
722723

723724
// ---------------------------------------------------------------------
724725

726+
void WsjcppLog::setRotationPeriodInSec(long nRotationPeriodInSec) {
727+
WsjcppLog::g_WSJCPP_LOG_ROTATION_PERIOD_IN_SECONDS = nRotationPeriodInSec;
728+
729+
}
730+
731+
// ---------------------------------------------------------------------
732+
725733
void WsjcppLog::initGlobalVariables() {
726734
// create deque if not created
727735
if (WsjcppLog::g_WSJCPP_LOG_LAST_MESSAGES == nullptr) {

src/wsjcpp_core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class WsjcppLog {
101101
static std::string g_WSJCPP_LOG_PREFIX_FILE;
102102
static std::string g_WSJCPP_LOG_FILE;
103103
static long g_WSJCPP_LOG_START_TIME;
104+
static long g_WSJCPP_LOG_ROTATION_PERIOD_IN_SECONDS;
104105
static std::mutex * g_WSJCPP_LOG_MUTEX;
105106
static std::deque<std::string> * g_WSJCPP_LOG_LAST_MESSAGES;
106107
static void doLogRotateUpdateFilename(bool bForce = false);
@@ -113,6 +114,7 @@ class WsjcppLog {
113114
static std::vector<std::string> getLastLogMessages();
114115
static void setLogDirectory(const std::string &sDirectoryPath);
115116
static void setPrefixLogFile(const std::string &sPrefixLogFile);
117+
static void setRotationPeriodInSec(long nRotationPeriodInSec);
116118
static void initGlobalVariables();
117119

118120
private:

unit-tests.wsjcpp/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
cmake_minimum_required(VERSION 3.0)
33

44
project(unit-tests C CXX)
5-
add_definitions(-DWSJCPP_VERSION="ut-v0.1.3")
5+
add_definitions(-DWSJCPP_VERSION="ut-v0.1.4")
66
add_definitions(-DWSJCPP_NAME="unit-tests-wsjcpp-core")
77

88
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
@@ -19,7 +19,7 @@ set (WSJCPP_SOURCES "")
1919
find_package(Threads REQUIRED)
2020
list (APPEND WSJCPP_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
2121

22-
# wsjcpp-core:v0.1.3
22+
# wsjcpp-core:v0.1.4
2323
list (APPEND WSJCPP_INCLUDE_DIRS "../src")
2424
list (APPEND WSJCPP_SOURCES "../src/wsjcpp_core.cpp")
2525
list (APPEND WSJCPP_SOURCES "../src/wsjcpp_core.h")

wsjcpp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cmake_cxx_standard: 11
33
cmake_minimum_required: 3.0
44

55
name: wsjcpp-core
6-
version: v0.1.3
6+
version: v0.1.4
77
description: Basic Utils for wsjcpp
88
issues: https://github.com/wsjcpp/wsjcpp-core/issues
99
repositories:

0 commit comments

Comments
 (0)