[Libreoffice-commits] core.git: include/sal sal/osl sal/util svl/source

2017-09-06 Thread Stephan Bergmann
 include/sal/backtrace.hxx|   11 ---
 sal/osl/unx/backtraceapi.cxx |4 ++--
 sal/osl/w32/backtrace.cxx|4 ++--
 sal/util/sal.map |4 ++--
 svl/source/notify/lstner.cxx |7 ---
 5 files changed, 18 insertions(+), 12 deletions(-)

New commits:
commit 796c494d78a851aae7d58e0720f64984cb5716de
Author: Stephan Bergmann 
Date:   Tue Sep 5 11:04:42 2017 +0200

Clean up sal/backtrace.hxx

Change-Id: Id78e9c0ca29ff2e52591f3d446431ac23c20ab7a
Reviewed-on: https://gerrit.libreoffice.org/41926
Tested-by: Jenkins 
Reviewed-by: Stephan Bergmann 

diff --git a/include/sal/backtrace.hxx b/include/sal/backtrace.hxx
index f437a3b73620..f471549b7f7a 100644
--- a/include/sal/backtrace.hxx
+++ b/include/sal/backtrace.hxx
@@ -23,20 +23,25 @@
   a small handful of recorded stack traces.
 
   @param backtraceDepth value indicating the maximum backtrace depth; must be 
> 0
+
+  @since LibreOffice 6.0
 */
 #if defined LIBO_INTERNAL_ONLY
 
+namespace sal {
+
 struct BacktraceState {
 void** buffer;
 int nDepth;
 ~BacktraceState() {delete[] buffer;}
 };
 
-SAL_DLLPUBLIC std::unique_ptr SAL_CALL sal_backtrace_get(
+SAL_DLLPUBLIC std::unique_ptr backtrace_get(
 sal_uInt32 backtraceDepth);
 
-SAL_DLLPUBLIC OUString SAL_CALL sal_backtrace_to_string(
-BacktraceState* backtraceState);
+SAL_DLLPUBLIC OUString backtrace_to_string(BacktraceState* backtraceState);
+
+}
 
 #endif
 
diff --git a/sal/osl/unx/backtraceapi.cxx b/sal/osl/unx/backtraceapi.cxx
index 4838474be36c..4216bf2cd07d 100644
--- a/sal/osl/unx/backtraceapi.cxx
+++ b/sal/osl/unx/backtraceapi.cxx
@@ -59,7 +59,7 @@ OUString osl::detail::backtraceAsString(sal_uInt32 maxDepth) {
 return b3.makeStringAndClear();
 }
 
-std::unique_ptr sal_backtrace_get(sal_uInt32 maxDepth)
+std::unique_ptr sal::backtrace_get(sal_uInt32 maxDepth)
 {
 assert(maxDepth != 0);
 auto const maxInt = static_cast(
@@ -72,7 +72,7 @@ std::unique_ptr sal_backtrace_get(sal_uInt32 
maxDepth)
 return std::unique_ptr(new BacktraceState{ b1, n });
 }
 
-OUString sal_backtrace_to_string(BacktraceState* backtraceState)
+OUString sal::backtrace_to_string(BacktraceState* backtraceState)
 {
 FreeGuard b2(backtrace_symbols(backtraceState->buffer, 
backtraceState->nDepth));
 if (b2.buffer == nullptr) {
diff --git a/sal/osl/w32/backtrace.cxx b/sal/osl/w32/backtrace.cxx
index 230adca4a2f8..574e4a450f48 100644
--- a/sal/osl/w32/backtrace.cxx
+++ b/sal/osl/w32/backtrace.cxx
@@ -65,7 +65,7 @@ OUString osl::detail::backtraceAsString(sal_uInt32 maxDepth)
 return aBuf.makeStringAndClear();
 }
 
-std::unique_ptr sal_backtrace_get(sal_uInt32 maxDepth)
+std::unique_ptr sal::backtrace_get(sal_uInt32 maxDepth)
 {
 assert(maxDepth != 0);
 auto const maxUlong = std::numeric_limits::max();
@@ -87,7 +87,7 @@ std::unique_ptr sal_backtrace_get(sal_uInt32 
maxDepth)
 return std::unique_ptr(new BacktraceState{ pStack, nFrames 
});
 }
 
-OUString sal_backtrace_to_string(BacktraceState* backtraceState)
+OUString sal::backtrace_to_string(BacktraceState* backtraceState)
 {
 OUStringBuffer aBuf;
 
diff --git a/sal/util/sal.map b/sal/util/sal.map
index e9195a1434f8..4bfe548d22f0 100644
--- a/sal/util/sal.map
+++ b/sal/util/sal.map
@@ -735,8 +735,8 @@ PRIVATE_1.3 { # LibreOffice 5.4
 
 PRIVATE_1.4 { # LibreOffice 6.0
 global:
-_Z17sal_backtrace_getj;
-_Z23sal_backtrace_to_stringP14BacktraceState;
+_ZN3sal13backtrace_getEj;
+_ZN3sal19backtrace_to_stringEPNS_14BacktraceStateE;
 } PRIVATE_1.3;
 
 PRIVATE_textenc.1 { # LibreOffice 3.6
diff --git a/svl/source/notify/lstner.cxx b/svl/source/notify/lstner.cxx
index 75928021351a..9c79da9e5185 100644
--- a/svl/source/notify/lstner.cxx
+++ b/svl/source/notify/lstner.cxx
@@ -35,7 +35,8 @@ struct SfxListener::Impl
 {
 SfxBroadcasterArr_Impl maBCs;
 #ifdef DBG_UTIL
-std::map maCallStacks;
+std::map
+maCallStacks;
 #endif
 };
 
@@ -95,7 +96,7 @@ void SfxListener::StartListening( SfxBroadcaster& 
rBroadcaster, bool bPreventDup
 if (bListeningAlready && !bPreventDuplicates)
 {
 auto f = mpImpl->maCallStacks.find(  );
-SAL_WARN("svl", "previous StartListening call came from: " << 
sal_backtrace_to_string(f->second.get()));
+SAL_WARN("svl", "previous StartListening call came from: " << 
sal::backtrace_to_string(f->second.get()));
 }
 #endif
 assert(!(bListeningAlready && !bPreventDuplicates) && "duplicate listener, 
try building with DBG_UTIL to find the other insert site.");
@@ -105,7 +106,7 @@ void SfxListener::StartListening( SfxBroadcaster& 
rBroadcaster, bool bPreventDup
 rBroadcaster.AddListener(*this);
 mpImpl->maBCs.push_back(  );
 #ifdef DBG_UTIL
-mpImpl->maCallStacks.emplace( , sal_backtrace_get(10) );
+

[Libreoffice-commits] core.git: include/sal sal/osl

2017-02-09 Thread Stephan Bergmann
 include/sal/log.hxx |6 +++---
 sal/osl/all/log.cxx |   28 +++-
 2 files changed, 10 insertions(+), 24 deletions(-)

New commits:
commit c697ae306cd4eaa8144ed93fc908e50d5934e249
Author: Stephan Bergmann 
Date:   Thu Feb 9 17:05:22 2017 +0100

Some clean up

No more need to call sal_detail_log_report from sal_detail_log, now that it 
is
called from SAL_DETAIL_LOG_STREAM since 
b3a11c8f4f307597c9c6e7e61ee93e794873
"tdf#91872: Make SAL_INFO and friends more efficient".

Change-Id: Idb6cf7a4814abe29d5ba68591f39b4279267bc9b

diff --git a/include/sal/log.hxx b/include/sal/log.hxx
index a21f80b..c096d52 100644
--- a/include/sal/log.hxx
+++ b/include/sal/log.hxx
@@ -27,11 +27,11 @@
 /// @cond INTERNAL
 
 extern "C" SAL_DLLPUBLIC void SAL_CALL sal_detail_log(
-enum sal_detail_LogLevel level, char const * area, char const * where,
+sal_detail_LogLevel level, char const * area, char const * where,
 char const * message, sal_uInt32 backtraceDepth);
 
-extern "C" SAL_DLLPUBLIC int SAL_CALL sal_detail_log_report(
-enum sal_detail_LogLevel level, char const * area);
+extern "C" SAL_DLLPUBLIC sal_Bool SAL_CALL sal_detail_log_report(
+sal_detail_LogLevel level, char const * area);
 
 namespace sal { namespace detail {
 
diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
index 774e7e8..0e15aab 100644
--- a/sal/osl/all/log.cxx
+++ b/sal/osl/all/log.cxx
@@ -186,11 +186,9 @@ void maybeOutputTimestamp(std::ostringstream ) {
 
 #endif
 
-bool isDebug(sal_detail_LogLevel level) {
-return level == SAL_DETAIL_LOG_LEVEL_DEBUG;
 }
 
-void log(
+void sal_detail_log(
 sal_detail_LogLevel level, char const * area, char const * where,
 char const * message, sal_uInt32 backtraceDepth)
 {
@@ -202,13 +200,13 @@ void log(
 maybeOutputTimestamp(s);
 s << toString(level) << ':';
 }
-if (!isDebug(level)) {
+if (level != SAL_DETAIL_LOG_LEVEL_DEBUG) {
 s << area << ':';
 }
 s << OSL_DETAIL_GETPID << ':';
 #endif
 s << osl::Thread::getCurrentIdentifier() << ':';
-if (isDebug(level)) {
+if (level == SAL_DETAIL_LOG_LEVEL_DEBUG) {
 s << ' ';
 } else {
 const size_t nStrLen(std::strlen(SRCDIR "/"));
@@ -216,13 +214,11 @@ void log(
   + (std::strncmp(where, SRCDIR "/", nStrLen) == 0
  ? nStrLen : 0));
 }
-
 s << message;
 if (backtraceDepth != 0) {
 s << " at:\n" << osl::detail::backtraceAsString(backtraceDepth);
 }
 s << '\n';
-
 #if defined ANDROID
 int android_log_level;
 switch (level) {
@@ -276,17 +272,6 @@ void log(
 #endif
 }
 
-}
-
-void sal_detail_log(
-sal_detail_LogLevel level, char const * area, char const * where,
-char const * message, sal_uInt32 backtraceDepth)
-{
-if (sal_detail_log_report(level, area)) {
-log(level, area, where, message, backtraceDepth);
-}
-}
-
 void sal_detail_logFormat(
 sal_detail_LogLevel level, char const * area, char const * where,
 char const * format, ...)
@@ -302,14 +287,15 @@ void sal_detail_logFormat(
 } else if (n >= len) {
 std::strcpy(buf + len - 1, "...");
 }
-log(level, area, where, buf, 0);
+sal_detail_log(level, area, where, buf, 0);
 va_end(args);
 }
 }
 
-int sal_detail_log_report(enum sal_detail_LogLevel level, char const * area) {
-if (isDebug(level))
+sal_Bool sal_detail_log_report(sal_detail_LogLevel level, char const * area) {
+if (level == SAL_DETAIL_LOG_LEVEL_DEBUG) {
 return true;
+}
 assert(area != nullptr);
 char const * env = getEnvironmentVariable();
 if (env == nullptr) {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/sal sal/osl sal/util

2017-02-03 Thread Arnold Dumas
 include/sal/log.hxx |5 +
 sal/osl/all/log.cxx |  162 ++--
 sal/util/sal.map|1 
 3 files changed, 86 insertions(+), 82 deletions(-)

New commits:
commit b3a11c8f4f307597c9c6e7e61ee93e794873
Author: Arnold Dumas 
Date:   Thu Feb 2 20:50:44 2017 +0100

tdf#91872: Make SAL_INFO and friends more efficient

Change-Id: I8a5b1665660b0679439f07d3924bb90cb4c4075c
Reviewed-on: https://gerrit.libreoffice.org/33848
Tested-by: Jenkins 
Reviewed-by: Noel Grandin 

diff --git a/include/sal/log.hxx b/include/sal/log.hxx
index 4438ec5..ea070dd 100644
--- a/include/sal/log.hxx
+++ b/include/sal/log.hxx
@@ -34,6 +34,9 @@ extern "C" SAL_DLLPUBLIC void SAL_CALL 
sal_detail_log_backtrace(
 enum sal_detail_LogLevel level, char const * area, char const * where,
 char const * message, int maxNoStackFramesToDisplay);
 
+extern "C" SAL_DLLPUBLIC int SAL_CALL sal_detail_log_report(
+enum sal_detail_LogLevel level, char const * area);
+
 namespace sal { namespace detail {
 
 inline void SAL_CALL log(
@@ -116,7 +119,7 @@ inline char const * unwrapStream(SAL_UNUSED_PARAMETER 
StreamIgnore const &) {
 
 #define SAL_DETAIL_LOG_STREAM(condition, level, area, where, stream) \
 do { \
-if (condition) { \
+if ((condition) && sal_detail_log_report(level, area)) { \
 if (sizeof ::sal::detail::getResult( \
 ::sal::detail::StreamStart() << stream) == 1) \
 { \
diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
index 7245a51..5e4497f 100644
--- a/sal/osl/all/log.cxx
+++ b/sal/osl/all/log.cxx
@@ -190,84 +190,6 @@ bool isDebug(sal_detail_LogLevel level) {
 return level == SAL_DETAIL_LOG_LEVEL_DEBUG;
 }
 
-bool report(sal_detail_LogLevel level, char const * area) {
-if (isDebug(level))
-return true;
-assert(area != nullptr);
-char const * env = getEnvironmentVariable();
-if (env == nullptr) {
-env = "+WARN";
-}
-std::size_t areaLen = std::strlen(area);
-enum Sense { POSITIVE = 0, NEGATIVE = 1 };
-std::size_t senseLen[2] = { 0, 1 };
-// initial senseLen[POSITIVE] < senseLen[NEGATIVE], so that if there 
are
-// no matching switches at all, the result will be negative (and
-// initializing with 1 is safe as the length of a valid switch, even
-// without the "+"/"-" prefix, will always be > 1)
-bool seenWarn = false;
-for (char const * p = env;;) {
-Sense sense;
-switch (*p++) {
-case '\0':
-if (level == SAL_DETAIL_LOG_LEVEL_WARN && !seenWarn)
-return report(SAL_DETAIL_LOG_LEVEL_INFO, area);
-return senseLen[POSITIVE] >= senseLen[NEGATIVE];
-// if a specific item is both positive and negative
-// (senseLen[POSITIVE] == senseLen[NEGATIVE]), default to
-// positive
-case '+':
-sense = POSITIVE;
-break;
-case '-':
-sense = NEGATIVE;
-break;
-default:
-return true; // upon an illegal SAL_LOG value, enable everything
-}
-char const * p1 = p;
-while (*p1 != '.' && *p1 != '+' && *p1 != '-' && *p1 != '\0') {
-++p1;
-}
-bool match;
-if (equalStrings(p, p1 - p, RTL_CONSTASCII_STRINGPARAM("INFO"))) {
-match = level == SAL_DETAIL_LOG_LEVEL_INFO;
-} else if (equalStrings(p, p1 - p, RTL_CONSTASCII_STRINGPARAM("WARN")))
-{
-match = level == SAL_DETAIL_LOG_LEVEL_WARN;
-seenWarn = true;
-} else if (equalStrings(p, p1 - p, 
RTL_CONSTASCII_STRINGPARAM("TIMESTAMP")) ||
-   equalStrings(p, p1 - p, 
RTL_CONSTASCII_STRINGPARAM("RELATIVETIMER")))
-{
-// handled later
-match = false;
-} else {
-return true;
-// upon an illegal SAL_LOG value, everything is considered
-// positive
-}
-char const * p2 = p1;
-while (*p2 != '+' && *p2 != '-' && *p2 != '\0') {
-++p2;
-}
-if (match) {
-if (*p1 == '.') {
-++p1;
-std::size_t n = p2 - p1;
-if ((n == areaLen && equalStrings(p1, n, area, areaLen))
-|| (n < areaLen && area[n] == '.'
-&& equalStrings(p1, n, area, n)))
-{
-senseLen[sense] = p2 - p;
-}
-} else {
-senseLen[sense] = p1 - p;
-}
-}
-p = p2;
-}
-}
-
 void log(
 sal_detail_LogLevel level, char const * area, char const * where,
 char const * message)
@@ -367,7 +289,7 @@ void sal_detail_log(
 sal_detail_LogLevel level, char const * area, char const * where,
 char const * 

[Libreoffice-commits] core.git: include/sal sal/osl

2016-12-13 Thread Stephan Bergmann
 include/sal/log-areas.dox |1 -
 sal/osl/unx/process.cxx   |   16 
 sal/osl/unx/signal.cxx|2 +-
 sal/osl/w32/profile.cxx   |   30 +++---
 sal/osl/w32/socket.cxx|2 +-
 5 files changed, 25 insertions(+), 26 deletions(-)

New commits:
commit 58fc735175c37ac9a31578481b8173054fb49f63
Author: Stephan Bergmann 
Date:   Tue Dec 13 11:03:55 2016 +0100

Reuse existing sal.osl log area

Change-Id: Ib1fc80c79355322489b7ebd37cb6614ec67a

diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox
index f812fc8..c343151e 100644
--- a/include/sal/log-areas.dox
+++ b/include/sal/log-areas.dox
@@ -20,7 +20,6 @@ certain functionality.
 
 @section SAL
 
-@li @c sal
 @li @c sal.bootstrap - SAL bootstrap
 @li @c sal.debug - SAL debugging functionality
 @li @c sal.file
diff --git a/sal/osl/unx/process.cxx b/sal/osl/unx/process.cxx
index b988798..21b24d3 100644
--- a/sal/osl/unx/process.cxx
+++ b/sal/osl/unx/process.cxx
@@ -181,7 +181,7 @@ static void ChildStatusProc(void *pData)
 OSL_ASSERT(geteuid() == 0); /* must be root */
 
 if (! INIT_GROUPS(data.m_name, data.m_gid) || (setuid(data.m_uid) 
!= 0))
-SAL_WARN("sal", "Failed to change uid and guid, errno=" << 
errno << " (" << strerror(errno) << ")" );
+SAL_WARN("sal.osl", "Failed to change uid and guid, errno=" << 
errno << " (" << strerror(errno) << ")" );
 
 const rtl::OUString envVar("HOME");
 osl_clearEnvironment(envVar.pData);
@@ -205,7 +205,7 @@ static void ChildStatusProc(void *pData)
 }
 }
 
-SAL_INFO("sal", "ChildStatusProc : starting " << 
data.m_pszArgs[0]);
+SAL_INFO("sal.osl", "ChildStatusProc : starting " << 
data.m_pszArgs[0]);
 
 /* Connect std IO to pipe ends */
 
@@ -243,14 +243,14 @@ static void ChildStatusProc(void *pData)
 execv(data.m_pszArgs[0], const_cast(data.m_pszArgs));
 }
 
-SAL_WARN("sal", "Failed to exec, errno=" << errno << " (" << 
strerror(errno) << ")");
+SAL_WARN("sal.osl", "Failed to exec, errno=" << errno << " (" << 
strerror(errno) << ")");
 
-SAL_WARN("sal", "ChildStatusProc : starting '" << data.m_pszArgs[0] << 
"' failed");
+SAL_WARN("sal.osl", "ChildStatusProc : starting '" << 
data.m_pszArgs[0] << "' failed");
 
 /* if we reach here, something went wrong */
 errno_copy = errno;
 if ( !safeWrite(channel[1], _copy, sizeof(errno_copy)) )
-SAL_WARN("sal", "sendFdPipe : sending failed (" << strerror(errno) 
<< ")");
+SAL_WARN("sal.osl", "sendFdPipe : sending failed (" << 
strerror(errno) << ")");
 
 if ( channel[1] != -1 )
 close(channel[1]);
@@ -309,7 +309,7 @@ static void ChildStatusProc(void *pData)
 
 if ( child_pid < 0)
 {
-SAL_WARN("sal", "Failed to wait for child process, errno=" << 
errno << " (" << strerror(errno) << ")");
+SAL_WARN("sal.osl", "Failed to wait for child process, errno=" 
<< errno << " (" << strerror(errno) << ")");
 
 /*
 We got an other error than EINTR. Anyway we have to wake up the
@@ -349,8 +349,8 @@ static void ChildStatusProc(void *pData)
 }
 else
 {
-SAL_WARN("sal", "ChildStatusProc : starting '" << 
data.m_pszArgs[0] << "' failed");
-SAL_WARN("sal", "Failed to launch child process, child reports 
errno=" << status << " (" << strerror(status) << ")");
+SAL_WARN("sal.osl", "ChildStatusProc : starting '" << 
data.m_pszArgs[0] << "' failed");
+SAL_WARN("sal.osl", "Failed to launch child process, child reports 
errno=" << status << " (" << strerror(status) << ")");
 
 /* Close pipe ends */
 if ( pdata->m_pInputWrite )
diff --git a/sal/osl/unx/signal.cxx b/sal/osl/unx/signal.cxx
index 69242d2..3892818 100644
--- a/sal/osl/unx/signal.cxx
+++ b/sal/osl/unx/signal.cxx
@@ -256,7 +256,7 @@ bool onInitSignal()
 if (sigemptyset() < 0 ||
 pthread_sigmask(SIG_SETMASK, , nullptr) < 0)
 {
-SAL_WARN("sal", "sigemptyset or pthread_sigmask failed");
+SAL_WARN("sal.osl", "sigemptyset or pthread_sigmask failed");
 }
 
 return true;
diff --git a/sal/osl/w32/profile.cxx b/sal/osl/w32/profile.cxx
index 6928c61..86592b0 100644
--- a/sal/osl/w32/profile.cxx
+++ b/sal/osl/w32/profile.cxx
@@ -191,23 +191,23 @@ oslProfile SAL_CALL osl_openProfile(rtl_uString 
*strProfileName, sal_uInt32 Flag
 
 if ( Flags == osl_Profile_DEFAULT )
 {
-SAL_INFO("sal", "with osl_Profile_DEFAULT");
+SAL_INFO("sal.osl", "with osl_Profile_DEFAULT");
 }
 if ( Flags & osl_Profile_SYSTEM )
 {
-SAL_INFO("sal", "with osl_Profile_SYSTEM");
+SAL_INFO("sal.osl", "with osl_Profile_SYSTEM");
 }
 if ( Flags & 

[Libreoffice-commits] core.git: include/sal sal/osl

2016-08-18 Thread Tor Lillqvist
 include/sal/log.hxx |3 +++
 sal/osl/all/log.cxx |   10 +++---
 2 files changed, 10 insertions(+), 3 deletions(-)

New commits:
commit 99ee4ebb0e934413bed881a02e4634e4d3f813ea
Author: Tor Lillqvist 
Date:   Thu Aug 18 16:55:11 2016 +0300

If no WARN in SAL_LOG, use the INFO selection for WARNs, too

Often the choice whether some particular message is displayed with
SAL_INFO or SAL_WARN has not necessarily been that well thought
through. Many SAL_WARNs are not actually warnings but purely
informative. If you want to see the INFOs for an area it makes sense
to want to see also the WARNs for it. So make it so, unless a specific
WARN selection is specified.

Change-Id: I6286c5f856b29e68bedb7f20efadf56953f94b72

diff --git a/include/sal/log.hxx b/include/sal/log.hxx
index e879a2f..8b4ef0a 100644
--- a/include/sal/log.hxx
+++ b/include/sal/log.hxx
@@ -262,6 +262,9 @@ inline char const * unwrapStream(SAL_UNUSED_PARAMETER 
StreamIgnore const &) {
 that has a sense of "+".  (That is, if both +INFO.foo and -INFO.foo are
 present, +INFO.foo wins.)
 
+If no WARN selection is specified, but an INFO selection is, the
+INFO selection is used for WARN messages, too.
+
 For example, if SAL_LOG is "+INFO-INFO.foo+INFO.foo.bar", then calls like
 SAL_INFO("foo.bar", ...), SAL_INFO("foo.bar.baz", ...), or
 SAL_INFO("other", ...) generate output, while calls like
diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
index 7f865f6..c1608b1 100644
--- a/sal/osl/all/log.cxx
+++ b/sal/osl/all/log.cxx
@@ -202,14 +202,17 @@ bool report(sal_detail_LogLevel level, char const * area) 
{
 // no matching switches at all, the result will be negative (and
 // initializing with 1 is safe as the length of a valid switch, even
 // without the "+"/"-" prefix, will always be > 1)
+bool seenWarn = false;
 for (char const * p = env;;) {
 Sense sense;
 switch (*p++) {
 case '\0':
+// if a specific item is both positive and negative
+// (senseLen[POSITIVE] == senseLen[NEGATIVE]), default to
+// positive
+if (level == SAL_DETAIL_LOG_LEVEL_WARN && !seenWarn)
+return report(SAL_DETAIL_LOG_LEVEL_INFO, area);
 return senseLen[POSITIVE] >= senseLen[NEGATIVE];
-// if a specific item is both positive and negative
-// (senseLen[POSITIVE] == senseLen[NEGATIVE]), default to
-// positive
 case '+':
 sense = POSITIVE;
 break;
@@ -229,6 +232,7 @@ bool report(sal_detail_LogLevel level, char const * area) {
 } else if (equalStrings(p, p1 - p, RTL_CONSTASCII_STRINGPARAM("WARN")))
 {
 match = level == SAL_DETAIL_LOG_LEVEL_WARN;
+seenWarn = true;
 } else if (equalStrings(p, p1 - p, 
RTL_CONSTASCII_STRINGPARAM("TIMESTAMP")) ||
equalStrings(p, p1 - p, 
RTL_CONSTASCII_STRINGPARAM("RELATIVETIMER")))
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/sal sal/osl

2016-08-18 Thread Tor Lillqvist
 include/sal/log.hxx |   21 +-
 sal/osl/all/log.cxx |   73 +++-
 2 files changed, 64 insertions(+), 30 deletions(-)

New commits:
commit ed815a242ef962afa52033a0d94ba6aa4539dd07
Author: Tor Lillqvist 
Date:   Thu Aug 18 15:31:25 2016 +0300

Add handling of a +RELATIVETIMER flag in the SAL_LOG environment variable

Outputs a timestamp in decimal seconds (with millisecond accuracy).

Simplified the handling of SAL_LOG if no "level" is specified. Now
just a totally unset (or empty) SAL_LOG causes the default of "+WARN"
to be used. Given how the code works, it would have become too
unwieldy to check for all combinations of TIMESTAMP and RELATIVETIMER
but no WARN or INFO.

Change-Id: I7bb5bb665d4e764e7eee447e93486f6467042e97

diff --git a/include/sal/log.hxx b/include/sal/log.hxx
index 6ce3bfe..e879a2f 100644
--- a/include/sal/log.hxx
+++ b/include/sal/log.hxx
@@ -231,18 +231,25 @@ inline char const * unwrapStream(SAL_UNUSED_PARAMETER 
StreamIgnore const &) {
::= 
::= "+"|"-"
::= |(".")?
-   ::= "TIMESTAMP"
+   ::= "TIMESTAMP"|"RELATIVETIMER"
::= "INFO"|"WARN"
 @endverbatim
 
-If the environment variable is unset, or contains no level, the level
-setting "+WARN" is assumed instead (which results in all warnings being
-output but no infos).  If the given value does not match the regular
-expression, "+INFO+WARN" is used instead (which in turn results in
-everything being output).
+If the environment variable is unset, the setting "+WARN" is
+assumed instead (which results in all warnings being output but no
+infos).  If the given value does not match the regular expression,
+"+INFO+WARN" is used instead (which in turn results in everything
+being output).
 
 The "+TIMESTAMP" flag causes each output line (as selected by the level
-switch(es)) to be prefixed by a timestamp like 2016-08-18:14:04:43..
+switch(es)) to be prefixed by a timestamp like 2016-08-18:14:04:43.
+
+The "+RELATIVETIMER" flag causes each output line (as selected by
+the level switch(es)) to be prefixed by a relative timestamp in
+seconds since the first output line like 1.312.
+
+If both +TIMESTAMP and +RELATIVETIMER are specified, they are
+output in that order.
 
 Specifying a flag with a negative sense has no effect. Specifying
 the same flag multiple times has no extra effect.
diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
index 276cbe4..7f865f6 100644
--- a/sal/osl/all/log.cxx
+++ b/sal/osl/all/log.cxx
@@ -109,9 +109,52 @@ void maybeOutputTimestamp(std::ostringstream ) {
 char const * env = getEnvironmentVariable();
 if (env == nullptr)
 return;
+bool outputTimestamp = false;
+bool outputRelativeTimer = false;
 for (char const * p = env;;) {
 switch (*p++) {
 case '\0':
+if (outputTimestamp) {
+char ts[100];
+TimeValue systemTime;
+osl_getSystemTime();
+TimeValue localTime;
+osl_getLocalTimeFromSystemTime(, );
+oslDateTime dateTime;
+osl_getDateTimeFromTimeValue(, );
+struct tm tm;
+tm.tm_sec = dateTime.Seconds;
+tm.tm_min = dateTime.Minutes;
+tm.tm_hour = dateTime.Hours;
+tm.tm_mday = dateTime.Day;
+tm.tm_mon = dateTime.Month - 1;
+tm.tm_year = dateTime.Year - 1900;
+strftime(ts, sizeof(ts), "%Y-%m-%d:%H:%M:%S", );
+char milliSecs[10];
+sprintf(milliSecs, "%03d", dateTime.NanoSeconds/100);
+s << ts << '.' << milliSecs << ':';
+}
+if (outputRelativeTimer) {
+static bool beenHere = false;
+static TimeValue first;
+if (!beenHere) {
+osl_getSystemTime();
+beenHere = true;
+}
+TimeValue now;
+osl_getSystemTime();
+int seconds = now.Seconds - first.Seconds;
+int milliSeconds;
+if (now.Nanosec < first.Nanosec) {
+seconds--;
+milliSeconds = 1000-(first.Nanosec-now.Nanosec)/100;
+}
+else
+milliSeconds = (now.Nanosec-first.Nanosec)/100;
+char relativeTimestamp[100];
+sprintf(relativeTimestamp, "%d.%03d", seconds, milliSeconds);
+s << relativeTimestamp << ':';
+}
 return;
 case '+':
 {
@@ -119,27 +162,10 @@ void maybeOutputTimestamp(std::ostringstream ) {
 while (*p1 != '.' && *p1 != '+' && *p1 != '-' && *p1 != '\0') {
 ++p1;
   

[Libreoffice-commits] core.git: include/sal sal/osl

2016-08-18 Thread Tor Lillqvist
 include/sal/log.hxx |   28 +++--
 sal/osl/all/log.cxx |   58 ++--
 2 files changed, 73 insertions(+), 13 deletions(-)

New commits:
commit fb00c725bba8b5ea30d47d28d0e54c071f1fe2a6
Author: Tor Lillqvist 
Date:   Thu Aug 18 14:07:00 2016 +0300

Add handling of a +TIMESTAMP flag in the SAL_LOG environment variable

Change-Id: I9bdcd8b2d7b46a087d7f5461b6f7c3d9f02ec084

diff --git a/include/sal/log.hxx b/include/sal/log.hxx
index e01d708..9465486 100644
--- a/include/sal/log.hxx
+++ b/include/sal/log.hxx
@@ -228,15 +228,21 @@ inline char const * unwrapStream(SAL_UNUSED_PARAMETER 
StreamIgnore const &) {
 with
 
 @verbatim
-   ::= (".")?
+   ::= 
::= "+"|"-"
+   ::= |(".")?
+   ::= "TIMESTAMP"
::= "INFO"|"WARN"
 @endverbatim
 
-If the environment variable is unset, "+WARN" is used instead (which 
results
-in all warnings being output but no infos).  If the given value does not
-match the regular expression, "+INFO+WARN" is used instead (which in turn
-results in everything being output).
+If the environment variable is unset, or contains no level, the level
+setting "+WARN" is assumed instead (which results in all warnings being
+output but no infos).  If the given value does not match the regular
+expression, "+INFO+WARN" is used instead (which in turn results in
+everything being output).
+
+The "+TIMESTAMP" flag causes each output line (as selected by the level
+switch(es)) to be prefixed by a timestamp like 2016-08-18:14:04:43.672.
 
 A given macro call's level (INFO or WARN) and area is matched against the
 given switches as follows:  Only those switches for which the level matches
@@ -251,12 +257,12 @@ inline char const * unwrapStream(SAL_UNUSED_PARAMETER 
StreamIgnore const &) {
 SAL_INFO("other", ...) generate output, while calls like
 SAL_INFO("foo", ...) or SAL_INFO("foo.barzzz", ...) do not.
 
-The generated log output consists of the given level ("info" or "warn"), 
the
-given area, the process ID, the thread ID, the source file, and the source
-line number, each followed by a colon, followed by a space, the given
-message, and a newline.  The precise format of the log output is subject to
-change.  The log output is printed to stderr without further text encoding
-conversion.
+The generated log output consists of the optinal timestamp, the given level
+("info" or "warn"), the given area, the process ID, the thread ID, the
+source file, and the source line number, each followed by a colon, followed
+by a space, the given message, and a newline.  The precise format of the 
log
+output is subject to change.  The log output is printed to stderr without
+further text encoding conversion.
 
 @see @ref sal_log_areas
 
diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
index 9c75393..da7eeeb 100644
--- a/sal/osl/all/log.cxx
+++ b/sal/osl/all/log.cxx
@@ -105,6 +105,55 @@ char const * getEnvironmentVariable() {
 return env;
 }
 
+void maybeOutputTimestamp(std::ostringstream ) {
+char const * env = getEnvironmentVariable();
+if (env == nullptr)
+return;
+for (char const * p = env;;) {
+switch (*p++) {
+case '\0':
+return;
+case '+':
+{
+char const * p1 = p;
+while (*p1 != '.' && *p1 != '+' && *p1 != '-' && *p1 != '\0') {
+++p1;
+}
+if (equalStrings(p, p1 - p, 
RTL_CONSTASCII_STRINGPARAM("TIMESTAMP"))) {
+char ts[100];
+TimeValue systemTime;
+osl_getSystemTime();
+TimeValue localTime;
+osl_getLocalTimeFromSystemTime(, );
+oslDateTime dateTime;
+osl_getDateTimeFromTimeValue(, );
+struct tm tm;
+tm.tm_sec = dateTime.Seconds;
+tm.tm_min = dateTime.Minutes;
+tm.tm_hour = dateTime.Hours;
+tm.tm_mday = dateTime.Day;
+tm.tm_mon = dateTime.Month - 1;
+tm.tm_year = dateTime.Year - 1900;
+strftime(ts, sizeof(ts), "%Y-%m-%d:%H:%M:%S", );
+char milliSecs[10];
+sprintf(milliSecs, "%03d", dateTime.NanoSeconds/100);
+s << ts << '.' << milliSecs << ':';
+return;
+}
+char const * p2 = p1;
+while (*p2 != '+' && *p2 != '-' && *p2 != '\0') {
+++p2;
+}
+p = p2;
+}
+break;
+default:
+; // nothing
+}
+}
+return;
+}
+
 #endif
 
 namespace {
@@ -119,7 +168,7 @@ bool report(sal_detail_LogLevel 

[Libreoffice-commits] core.git: include/sal sal/osl

2016-03-04 Thread Stephan Bergmann
 include/sal/log-areas.dox |1 -
 sal/osl/w32/socket.cxx|4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)

New commits:
commit d7c4c45bc8daa9e3dffe2d5d6557c250f1d683c0
Author: Stephan Bergmann 
Date:   Fri Mar 4 12:35:42 2016 +0100

Use existing "sal.osl" log area

Change-Id: I7d48c1543b0d3239c8e646ca0765421f933cfecc

diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox
index 3bc2ace..d2de637 100644
--- a/include/sal/log-areas.dox
+++ b/include/sal/log-areas.dox
@@ -30,7 +30,6 @@ certain functionality.
 @li @c sal.rtl - SAL RTL library
 @li @c sal.rtl.xub - SAL RTL warnings related to possible String->OUString 
conversion issues.
 @li @c sal.textenc - the textencoding SAL library
-@li @c sal.w32
 
 @section basctl
 
diff --git a/sal/osl/w32/socket.cxx b/sal/osl/w32/socket.cxx
index e3aad35..a0d1340 100644
--- a/sal/osl/w32/socket.cxx
+++ b/sal/osl/w32/socket.cxx
@@ -412,8 +412,8 @@ struct LeakWarning
 {
 ~LeakWarning()
 {
-SAL_WARN_IF( g_nSocketImpl, "sal.w32", "sal_socket: " << g_nSocketImpl 
<< " socket instances leak" );
-SAL_WARN_IF( g_nSocketAddr, "sal.w32", "sal_socket: " << g_nSocketAddr 
<< " socket address instances leak" );
+SAL_WARN_IF( g_nSocketImpl, "sal.osl", "sal_socket: " << g_nSocketImpl 
<< " socket instances leak" );
+SAL_WARN_IF( g_nSocketAddr, "sal.osl", "sal_socket: " << g_nSocketAddr 
<< " socket address instances leak" );
 }
 };
 LeakWarning socketWarning;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/sal sal/osl sal/qa sal/rtl sal/test

2016-03-03 Thread Rohan Kumar
 include/sal/log-areas.dox   |4 +++
 sal/osl/unx/profile.cxx |4 +--
 sal/osl/unx/socket.cxx  |   10 
 sal/osl/w32/socket.cxx  |   12 --
 sal/qa/osl/process/osl_process.cxx  |   24 ++---
 sal/qa/rtl/doublelock/rtl_doublelocking.cxx |   15 +++--
 sal/rtl/bootstrap.cxx   |   32 
 sal/test/testbootstrap.cxx  |   17 +-
 8 files changed, 43 insertions(+), 75 deletions(-)

New commits:
commit f59136a2ed1e3eb01cc5b62c5a7da07c34cbdfae
Author: Rohan Kumar 
Date:   Wed Mar 2 01:28:58 2016 +0530

tdf#91794 remove OSL_DEBUG_LEVEL > 1 conditionals

Change-Id: If329cf8257684e7bd2936641b8f14ec3e9b9f733
Reviewed-on: https://gerrit.libreoffice.org/22647
Reviewed-by: Eike Rathke 
Tested-by: Eike Rathke 

diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox
index d2de637..d4a020a 100644
--- a/include/sal/log-areas.dox
+++ b/include/sal/log-areas.dox
@@ -30,6 +30,10 @@ certain functionality.
 @li @c sal.rtl - SAL RTL library
 @li @c sal.rtl.xub - SAL RTL warnings related to possible String->OUString 
conversion issues.
 @li @c sal.textenc - the textencoding SAL library
+@li @c sal.w32
+@li @c sal.test
+@li @c sal.process
+@li @c sal.doublelock
 
 @section basctl
 
diff --git a/sal/osl/unx/profile.cxx b/sal/osl/unx/profile.cxx
index 8cad965..9cbab6b 100644
--- a/sal/osl/unx/profile.cxx
+++ b/sal/osl/unx/profile.cxx
@@ -320,7 +320,7 @@ sal_Bool SAL_CALL osl_flushProfile(oslProfile Profile)
 
 static bool writeProfileImpl(osl_TFile* pFile)
 {
-#if OSL_DEBUG_LEVEL > 1
+#if OSL_DEBUG_LEVEL > 0
 unsigned int nLen=0;
 #endif
 
@@ -329,7 +329,7 @@ static bool writeProfileImpl(osl_TFile* pFile)
 return false;
 }
 
-#if OSL_DEBUG_LEVEL > 1
+#if OSL_DEBUG_LEVEL > 0
 nLen=strlen(pFile->m_pWriteBuf);
 SAL_WARN_IF(nLen != (pFile->m_nWriteBufLen - pFile->m_nWriteBufFree), 
"sal.osl", "nLen != (pFile->m_nWriteBufLen - pFile->m_nWriteBufFree)");
 #endif
diff --git a/sal/osl/unx/socket.cxx b/sal/osl/unx/socket.cxx
index 190e7c3..1065c79 100644
--- a/sal/osl/unx/socket.cxx
+++ b/sal/osl/unx/socket.cxx
@@ -429,7 +429,7 @@ oslSocketResult SAL_CALL 
osl_psz_getDottedInetAddrOfSocketAddr (
 void SAL_CALL osl_psz_getLastSocketErrorDescription (
 oslSocket Socket, sal_Char* pBuffer, sal_uInt32 BufferSize);
 
-#if OSL_DEBUG_LEVEL > 1
+#if OSL_DEBUG_LEVEL > 0
 static sal_uInt32 g_nSocketImpl = 0;
 static sal_uInt32 g_nSocketAddr = 0;
 
@@ -451,7 +451,7 @@ oslSocket __osl_createSocketImpl(int Socket)
 pSocket->m_bIsAccepting = false;
 #endif
 
-#if OSL_DEBUG_LEVEL > 1
+#if OSL_DEBUG_LEVEL > 0
 g_nSocketImpl ++;
 #endif
 return pSocket;
@@ -461,7 +461,7 @@ void __osl_destroySocketImpl(oslSocket Socket)
 {
 if ( Socket != nullptr)
 free(Socket);
-#if OSL_DEBUG_LEVEL > 1
+#if OSL_DEBUG_LEVEL > 0
 g_nSocketImpl --;
 #endif
 }
@@ -469,7 +469,7 @@ void __osl_destroySocketImpl(oslSocket Socket)
 static oslSocketAddr __osl_createSocketAddr()
 {
 oslSocketAddr pAddr = static_cast(rtl_allocateZeroMemory( 
sizeof( struct oslSocketAddrImpl )));
-#if OSL_DEBUG_LEVEL > 1
+#if OSL_DEBUG_LEVEL > 0
 g_nSocketAddr ++;
 #endif
 return pAddr;
@@ -509,7 +509,7 @@ static oslSocketAddr __osl_createSocketAddrFromSystem( 
struct sockaddr *pSystemS
 
 static void __osl_destroySocketAddr( oslSocketAddr addr )
 {
-#if OSL_DEBUG_LEVEL > 1
+#if OSL_DEBUG_LEVEL > 0
 g_nSocketAddr --;
 #endif
 rtl_freeMemory( addr );
diff --git a/sal/osl/w32/socket.cxx b/sal/osl/w32/socket.cxx
index 927da21..e3aad35 100644
--- a/sal/osl/w32/socket.cxx
+++ b/sal/osl/w32/socket.cxx
@@ -406,16 +406,14 @@ static sal_Bool __osl_attemptSocketDialupImpl()
 /*/
 static sal_uInt32 g_nSocketImpl = 0;
 
-#if OSL_DEBUG_LEVEL > 1
+#if OSL_DEBUG_LEVEL > 0
 static sal_uInt32 g_nSocketAddr = 0;
 struct LeakWarning
 {
 ~LeakWarning()
 {
-if( g_nSocketImpl )
-OSL_TRACE( "sal_socket: %d socket instances leak" , g_nSocketImpl 
);
-if( g_nSocketAddr )
-OSL_TRACE( "sal_socket: %d socket address instances leak" , 
g_nSocketAddr );
+SAL_WARN_IF( g_nSocketImpl, "sal.w32", "sal_socket: " << g_nSocketImpl 
<< " socket instances leak" );
+SAL_WARN_IF( g_nSocketAddr, "sal.w32", "sal_socket: " << g_nSocketAddr 
<< " socket address instances leak" );
 }
 };
 LeakWarning socketWarning;
@@ -455,7 +453,7 @@ static oslSocketAddr __osl_createSocketAddr(  )
 {
 oslSocketAddr pAddr = (oslSocketAddr) rtl_allocateZeroMemory( sizeof( 
struct oslSocketAddrImpl ));
 pAddr->m_nRefCount = 1;
-#if OSL_DEBUG_LEVEL > 1
+#if OSL_DEBUG_LEVEL > 0
 g_nSocketAddr ++;
 #endif
 return pAddr;
@@ -493,7 +491,7 @@ static