summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormykola.salomatin <mykola.salomatin@globallogic.com>2020-11-10 12:59:25 +0200
committermykola.salomatin <mykola.salomatin@globallogic.com>2020-11-10 12:59:25 +0200
commitf5122928882ebfb0f68bd7b17bc4c6fe95a7bbb6 (patch)
treed0fc2765f53db02550a81cde3883a9160e937772
parentec167ba35669434dc1aadebd4e03c44fc5b04133 (diff)
downloadlibmts-f5122928882ebfb0f68bd7b17bc4c6fe95a7bbb6.tar.gz
libmts-f5122928882ebfb0f68bd7b17bc4c6fe95a7bbb6.tar.bz2
libmts-f5122928882ebfb0f68bd7b17bc4c6fe95a7bbb6.zip
[MTX-3669] mPower Release 5.4: alertservice and libmts shall print log messages to stderr
-rw-r--r--include/mts/MTS_Logger.h3
-rw-r--r--src/MTS_Logger.cpp13
2 files changed, 15 insertions, 1 deletions
diff --git a/include/mts/MTS_Logger.h b/include/mts/MTS_Logger.h
index b0beda9..e203199 100644
--- a/include/mts/MTS_Logger.h
+++ b/include/mts/MTS_Logger.h
@@ -117,7 +117,8 @@ namespace MTS {
SYSLOG_ONLY,
STDOUT_AND_FILE,
STDOUT_AND_SYSLOG,
- STDERR_ONLY
+ STDERR_ONLY,
+ STDERR_AND_SYSLOG
};
static int getPrintLevel();
diff --git a/src/MTS_Logger.cpp b/src/MTS_Logger.cpp
index eb879e3..1be2a0f 100644
--- a/src/MTS_Logger.cpp
+++ b/src/MTS_Logger.cpp
@@ -172,6 +172,19 @@ void Logger::printMessage(const int32_t& level, const char* label, const char* f
}
break;
+ case Logger::PrintMode::STDERR_AND_SYSLOG: {
+ if (level <= Logger::PrintLevel::TRACE_LEVEL) {
+ va_list argptr2;
+ va_copy(argptr2, argptr);
+ vsyslog(syslogPrintLevelConversion(level), format, argptr2);
+ va_end(argptr2);
+ }
+ fprintf(stderr, "%s|%s|", MTS::Text::time(MTS::System::timeMicros()).c_str(), label);
+ vfprintf(stderr, format, argptr);
+ fprintf(stderr, "\n");
+ }
+ break;
+
case Logger::PrintMode::NO_PRINTING:
default:
break;