Skip to content

Commit 0b194eb

Browse files
committed
Added getLastLogMessages
1 parent 8309b33 commit 0b194eb

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/wsjcpp_core.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,18 @@ void WSJCppLog::ok(const std::string &sTag, const std::string &sMessage) {
535535

536536
// ---------------------------------------------------------------------
537537

538+
std::vector<std::string> WSJCppLog::getLastLogMessages() {
539+
WSJCppLog::initGlobalVariables();
540+
std::lock_guard<std::mutex> lock(*WSJCppLog::g_WSJCPP_LOG_MUTEX);
541+
std::vector<std::string> vRet;
542+
for (int i = 0; i < g_WSJCPP_LOG_LAST_MESSAGES->size(); i++) {
543+
vRet.push_back(g_WSJCPP_LOG_LAST_MESSAGES->at(i));
544+
}
545+
return vRet;
546+
}
547+
548+
// ---------------------------------------------------------------------
549+
538550
void WSJCppLog::setLogDirectory(const std::string &sDirectoryPath) {
539551
WSJCppLog::g_WSJCPP_LOG_DIR = sDirectoryPath;
540552
WSJCppLog::doLogRotateUpdateFilename(true);

src/wsjcpp_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class WSJCppLog {
100100
static void throw_err(const std::string &sTag, const std::string &sMessage);
101101
static void warn(const std::string &sTag, const std::string &sMessage);
102102
static void ok(const std::string &sTag, const std::string &sMessage);
103+
static std::vector<std::string> getLastLogMessages();
103104
static void setLogDirectory(const std::string &sDirectoryPath);
104105
static void setPrefixLogFile(const std::string &sPrefixLogFile);
105106
static void initGlobalVariables();

0 commit comments

Comments
 (0)