summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2011-11-23 15:45:43 +0100
committerStephan Bergmann <sbergman@redhat.com>2011-11-23 15:50:58 +0100
commit0c7bff02710f8ad7915e215f723b6abad0079221 (patch)
tree30ddfb6fedcd954f91bfa24f36df1dd7413804c4 /sal
parentf4573ceb2965ccc8abc1f5165b0fa63f5d63649f (diff)
Changed sal/log.h -> sal/log.hxx, drop _S from C++ streaming log macros.
A compile time check ensures the common case of streaming just a plain C-style string literal still produces reasonably compact call-site code. The format-string variants are still available in sal/detail/log.h, but only to be used in obsolete osl/diagnose.h etc., and going to be removed again eventually.
Diffstat (limited to 'sal')
-rw-r--r--sal/inc/osl/diagnose.h17
-rw-r--r--sal/inc/osl/diagnose.hxx2
-rw-r--r--sal/inc/rtl/string.hxx2
-rw-r--r--sal/inc/rtl/ustring.hxx2
-rw-r--r--sal/inc/sal/detail/log.h111
-rw-r--r--sal/inc/sal/log.hxx (renamed from sal/inc/sal/log.h)203
-rw-r--r--sal/osl/all/log.cxx3
-rw-r--r--sal/osl/all/logformat.hxx2
-rw-r--r--sal/osl/all/trace.cxx3
-rw-r--r--sal/osl/unx/conditn.cxx (renamed from sal/osl/unx/conditn.c)87
-rw-r--r--sal/prj/d.lst3
-rw-r--r--sal/rtl/source/logfile.cxx6
12 files changed, 267 insertions, 174 deletions
diff --git a/sal/inc/osl/diagnose.h b/sal/inc/osl/diagnose.h
index 0e1fc443e67e..12357aa9bd61 100644
--- a/sal/inc/osl/diagnose.h
+++ b/sal/inc/osl/diagnose.h
@@ -32,7 +32,7 @@
#include "sal/config.h"
-#include <sal/log.h>
+#include <sal/detail/log.h>
#include <sal/types.h>
/** provides simple diagnostic support
@@ -42,7 +42,7 @@
if an assertion fails, and is controlled by the standard NDEBUG macro).
Logging of warnings (e.g., about malformed input) and traces (e.g., about
steps taken while executing some protocol) should use the facilities
- provided by sal/log.h.
+ provided by (C++ only) sal/log.hxx.
Because the assertion macros (OSL_ASSERT, OSL_ENSURE, OSL_FAIL, OSL_PRECOND,
and OSL_POSTCOND) have been used for true assertions as well as for logged
@@ -139,19 +139,20 @@ pfunc_osl_printDetailedDebugMessage SAL_CALL osl_setDetailedDebugMessageFunc( pf
/* the macro OSL_LOG_PREFIX is intended to be an office internal macro for now
- it is deprecated and superseded by SAL_WHERE
+ it is deprecated and superseded by (C++ only) SAL_WHERE
*/
-#define OSL_LOG_PREFIX SAL_WHERE
+#define OSL_LOG_PREFIX SAL_DETAIL_WHERE
#define OSL_DEBUG_ONLY(s) _OSL_DEBUG_ONLY(s)
#define OSL_TRACE(...) \
- SAL_INFO_IF(OSL_DEBUG_LEVEL > 0, "legacy.osl", __VA_ARGS__)
+ SAL_DETAIL_INFO_IF_FORMAT(OSL_DEBUG_LEVEL > 0, "legacy.osl", __VA_ARGS__)
#if OSL_DEBUG_LEVEL > 0
-#define OSL_ASSERT(c) SAL_WARN_IF(!(c), "legacy.osl", "OSL_ASSERT")
-#define OSL_ENSURE(c, m) SAL_WARN_IF(!(c), "legacy.osl", "%s", m)
-#define OSL_FAIL(m) SAL_WARN_IF(sal_True, "legacy.osl", "%s", m)
+#define OSL_ASSERT(c) \
+ SAL_DETAIL_WARN_IF_FORMAT(!(c), "legacy.osl", "OSL_ASSERT")
+#define OSL_ENSURE(c, m) SAL_DETAIL_WARN_IF_FORMAT(!(c), "legacy.osl", "%s", m)
+#define OSL_FAIL(m) SAL_DETAIL_WARN_IF_FORMAT(sal_True, "legacy.osl", "%s", m)
#else
#define OSL_ASSERT(c) ((void) 0)
#define OSL_ENSURE(c, m) ((void) 0)
diff --git a/sal/inc/osl/diagnose.hxx b/sal/inc/osl/diagnose.hxx
index 42e4b8dd7f2f..45a6fdd3cf7c 100644
--- a/sal/inc/osl/diagnose.hxx
+++ b/sal/inc/osl/diagnose.hxx
@@ -39,7 +39,7 @@
#include "osl/mutex.hxx"
#include "rtl/allocator.hxx"
#include "rtl/instance.hxx"
-#include "sal/log.h"
+#include "sal/log.hxx"
#include "sal/types.h"
namespace osl {
diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx
index 007129a7dc0f..0db8341a8930 100644
--- a/sal/inc/rtl/string.hxx
+++ b/sal/inc/rtl/string.hxx
@@ -37,7 +37,7 @@
#include <rtl/memory.h>
#include <rtl/textenc.h>
#include <rtl/string.h>
-#include "sal/log.h"
+#include "sal/log.hxx"
#if !defined EXCEPTIONS_OFF
#include <new>
diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx
index ef13dd1da387..868f6dd043cd 100644
--- a/sal/inc/rtl/ustring.hxx
+++ b/sal/inc/rtl/ustring.hxx
@@ -37,7 +37,7 @@
#include <rtl/ustring.h>
#include <rtl/string.hxx>
#include <rtl/memory.h>
-#include "sal/log.h"
+#include "sal/log.hxx"
#if defined EXCEPTIONS_OFF
#include <stdlib.h>
diff --git a/sal/inc/sal/detail/log.h b/sal/inc/sal/detail/log.h
new file mode 100644
index 000000000000..bc51b89b6b14
--- /dev/null
+++ b/sal/inc/sal/detail/log.h
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * [ Copyright (C) 2011 Stephan Bergmann, Red Hat <sbergman@redhat.com> (initial
+ * developer) ]
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef INCLUDED_SAL_DETAIL_LOG_H
+#define INCLUDED_SAL_DETAIL_LOG_H
+
+#include "sal/config.h"
+
+#include "sal/types.h"
+
+/** @internal */
+
+/* This header makes available replacements working in both C and C++ for the
+ obsolete osl/diagnose.h functionality that in turn is used from both C and
+ C++ code and the obsolete tools/debug.hxx and
+ canvas/inc/canvas/verbosetrace.hxx functionality that uses printf-style
+ formatting. Once that obsolete functionality is removed, this header can be
+ removed, too.
+
+ This header uses variadic macros in both C (where they are officially only
+ supported since C99) and C++ (where they are officially only supported since
+ C++11). It appears that all relevant compilers (esp. GCC 4.0 and MS VS 2008
+ Express) already support them in their C and C++ dialects. See also
+ <http://wiki.apache.org/stdcxx/C++0xCompilerSupport>.
+
+ Avoid the use of other sal code in this header as much as possible, so that
+ this code can be called from other sal code without causing endless
+ recursion.
+*/
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+enum sal_detail_LogLevel {
+ SAL_DETAIL_LOG_LEVEL_INFO, SAL_DETAIL_LOG_LEVEL_WARN,
+ SAL_DETAIL_MAKE_FIXED_SIZE = SAL_MAX_ENUM
+};
+
+void SAL_CALL sal_detail_logFormat(
+ enum sal_detail_LogLevel level, char const * area, char const * where,
+ char const * format, ...)
+/* TODO: enabling this will produce a huge amount of -Werror=format errors: */
+#if defined GCC && 0
+ __attribute__((format(printf, 4, 5)))
+#endif
+ ;
+
+#if defined __cplusplus
+}
+#endif
+
+#define SAL_DETAIL_LOG_FORMAT(condition, level, area, where, ...) \
+ do { \
+ if (condition) { \
+ sal_detail_logFormat((level), (area), (where), __VA_ARGS__); \
+ } \
+ } while (sal_False)
+
+#if defined SAL_LOG_INFO
+#define SAL_DETAIL_ENABLE_LOG_INFO sal_True
+#else
+#define SAL_DETAIL_ENABLE_LOG_INFO sal_False
+#endif
+#if defined SAL_LOG_WARN
+#define SAL_DETAIL_ENABLE_LOG_WARN sal_True
+#else
+#define SAL_DETAIL_ENABLE_LOG_WARN sal_False
+#endif
+
+#define SAL_DETAIL_WHERE __FILE__ ":" SAL_STRINGIFY(__LINE__) ": "
+
+#define SAL_DETAIL_INFO_IF_FORMAT(condition, area, ...) \
+ SAL_DETAIL_LOG_FORMAT( \
+ SAL_DETAIL_ENABLE_LOG_INFO && (condition), SAL_DETAIL_LOG_LEVEL_INFO, \
+ area, SAL_DETAIL_WHERE, __VA_ARGS__)
+
+#define SAL_DETAIL_WARN_IF_FORMAT(condition, area, ...) \
+ SAL_DETAIL_LOG_FORMAT( \
+ SAL_DETAIL_ENABLE_LOG_WARN && (condition), SAL_DETAIL_LOG_LEVEL_WARN, \
+ area, SAL_DETAIL_WHERE, __VA_ARGS__)
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/inc/sal/log.h b/sal/inc/sal/log.hxx
index d63ed6b32752..be71d021d560 100644
--- a/sal/inc/sal/log.h
+++ b/sal/inc/sal/log.hxx
@@ -27,71 +27,30 @@
* instead of those above.
*/
-#ifndef INCLUDED_SAL_LOG_H
-#define INCLUDED_SAL_LOG_H
+#ifndef INCLUDED_SAL_LOG_HXX
+#define INCLUDED_SAL_LOG_HXX
#include "sal/config.h"
-#if defined __cplusplus
+#include <cstdlib>
#include <sstream>
#include <string>
-#endif
+#include "sal/detail/log.h"
#include "sal/types.h"
-/* This header uses variadic macros in both C (where they are officially only
- supported since C99) and C++ (where they are officially only supported since
- C++11). It appears that all relevant compilers (esp. GCC 4.0 and MS VS 2008
- Express) already support them in their C and C++ dialects. See also
- <http://wiki.apache.org/stdcxx/C++0xCompilerSupport>.
-
- Avoid the use of other sal code in this header as much as possible, so that
- this code can be called from other sal code without causing endless
- recursion.
-*/
-
-#if defined __cplusplus
-extern "C" {
-#endif
-
-/** @internal */
-enum sal_detail_LogLevel {
- SAL_DETAIL_LOG_LEVEL_INFO, SAL_DETAIL_LOG_LEVEL_WARN,
- SAL_DETAIL_MAKE_FIXED_SIZE = SAL_MAX_ENUM
-};
+// Avoid the use of other sal code in this header as much as possible, so that
+// this code can be called from other sal code without causing endless
+// recursion.
-/** @internal */
-void SAL_CALL sal_detail_log(
+/// @internal
+extern "C" void SAL_CALL sal_detail_log(
enum sal_detail_LogLevel level, char const * area, char const * where,
char const * message);
-/** @internal */
-void SAL_CALL sal_detail_logFormat(
- enum sal_detail_LogLevel level, char const * area, char const * where,
- char const * format, ...)
-/* TODO: enabling this will produce a huge amount of -Werror=format errors: */
-#if defined GCC && 0
- __attribute__((format(printf, 4, 5)))
-#endif
- ;
-
-#if defined __cplusplus
-}
-#endif
-
-/** @internal */
-#define SAL_DETAIL_LOG_FORMAT(condition, level, area, where, ...) \
- do { \
- if (condition) { \
- sal_detail_logFormat((level), (area), (where), __VA_ARGS__); \
- } \
- } while (sal_False)
-
-#if defined __cplusplus
-
+/// @internal
namespace sal { namespace detail {
-/// @internal
inline void SAL_CALL log(
sal_detail_LogLevel level, char const * area, char const * where,
std::ostringstream const & stream)
@@ -107,32 +66,72 @@ inline void SAL_CALL log(
sal_detail_log(level, area, where, stream.str().c_str());
}
+// Special handling of the common case where the message consists of just a
+// string literal, to produce smaller call-site code:
+
+struct StreamStart {};
+
+struct StreamString {
+ StreamString(char const * s): string(s) {}
+
+ char const * string;
+
+ typedef char Result;
+};
+
+struct StreamIgnore {
+ typedef struct { char a[2]; } Result;
+};
+
+inline StreamString operator <<(StreamStart const &, char const * s) {
+ return StreamString(s);
+}
+
+template< typename T > inline StreamIgnore operator <<(
+ StreamStart const &, T const &)
+{
+ std::abort();
+}
+
+template< typename T > inline StreamIgnore operator <<(
+ StreamString const &, T const &)
+{
+ std::abort();
+}
+
+template< typename T > inline StreamIgnore operator <<(
+ StreamIgnore const &, T const &)
+{
+ std::abort();
+}
+
+template< typename T > typename T::Result getResult(T const &);
+
+inline char const * unwrapStream(StreamString const & s) { return s.string; }
+
+inline char const * unwrapStream(StreamIgnore const &) { std::abort(); }
+
} }
/// @internal
#define SAL_DETAIL_LOG_STREAM(condition, level, area, where, stream) \
do { \
if (condition) { \
- ::std::ostringstream sal_detail_stream; \
- sal_detail_stream << stream; \
- ::sal::detail::log((level), (area), (where), sal_detail_stream); \
+ if (sizeof getResult(::sal::detail::StreamStart() << stream) == 1) \
+ { \
+ ::sal_detail_log( \
+ (level), (area), (where), \
+ ::sal::detail::unwrapStream( \
+ ::sal::detail::StreamStart() << stream)); \
+ } else { \
+ ::std::ostringstream sal_detail_stream; \
+ sal_detail_stream << stream; \
+ ::sal::detail::log( \
+ (level), (area), (where), sal_detail_stream); \
+ } \
} \
} while (false)
-#endif
-
-/** @internal */
-#if defined SAL_LOG_INFO
-#define SAL_DETAIL_ENABLE_LOG_INFO sal_True
-#else
-#define SAL_DETAIL_ENABLE_LOG_INFO sal_False
-#endif
-#if defined SAL_LOG_WARN
-#define SAL_DETAIL_ENABLE_LOG_WARN sal_True
-#else
-#define SAL_DETAIL_ENABLE_LOG_WARN sal_False
-#endif
-
/** A simple macro to create a "file and line number" string.
Potentially not only useful within the log framework (where it is used
@@ -140,19 +139,16 @@ inline void SAL_CALL log(
@since LibreOffice 3.5
*/
-#define SAL_WHERE __FILE__ ":" SAL_STRINGIFY(__LINE__) ": "
-
-#if defined __cplusplus
+#define SAL_WHERE SAL_DETAIL_WHERE
/** A facility for generating temporary string messages by piping items into a
C++ std::ostringstream.
- This can be useful for example in a call to SAL_INFO_S when depending on
- some boolean condition data of incompatible types shall be streamed into the
+ This can be useful for example in a call to SAL_INFO when depending on some
+ boolean condition data of incompatible types shall be streamed into the
message, as in:
- SAL_INFO_S(
- "foo", "object: " << (hasName ? obj->name : SAL_STREAM(obj)));
+ SAL_INFO("foo", "object: " << (hasName ? obj->name : SAL_STREAM(obj)));
@since LibreOffice 3.5
*/
@@ -160,28 +156,18 @@ inline void SAL_CALL log(
(dynamic_cast< ::std::ostringstream & >(::std::ostringstream() << stream). \
str())
-#endif
-
/** Basic logging functionality.
- SAL_INFO(char const * area, char const * format, ...),
- SAL_INFO_IF(bool condition, char const * area, char const * format, ...),
- SAL_WARN(char const * area, char const * format, ...), and
- SAL_WARN_IF(bool condition, char const * area, char const * format, ...)
- produce an info resp. warning log entry with a printf-style message. The
- given format argument and any following arguments must be so that that
- sequence of arguments would be appropriate for a call to printf.
-
- SAL_INFO_S(char const * area, expr),
- SAL_INFO_IF_S(bool condition, char const * area, expr),
- SAL_WARN_S(char const * area, expr), and
- SAL_WARN_IF_S(bool condition, char const * area, expr) produce an info resp.
+ SAL_INFO(char const * area, expr),
+ SAL_INFO_IF(bool condition, char const * area, expr),
+ SAL_WARN(char const * area, expr), and
+ SAL_WARN_IF(bool condition, char const * area, expr) produce an info resp.
warning log entry with a message produced by piping items into a C++
- std::ostringstream (and are only available in C++). The given expr must be
- so that the full expression "stream << expr" is valid, where stream is a
- variable of type std::ostringstream.
+ std::ostringstream. The given expr must be so that the full expression
+ "stream << expr" is valid, where stream is a variable of type
+ std::ostringstream.
- SAL_INFO_S("foo", "string " << s << " of length " << n)
+ SAL_INFO("foo", "string " << s << " of length " << n)
would be an example of such a call; if the given s is of type rtl::OUString,
@@ -252,48 +238,25 @@ inline void SAL_CALL log(
@since LibreOffice 3.5
*/
-#define SAL_INFO(area, ...) \
- SAL_DETAIL_LOG_FORMAT( \
- SAL_DETAIL_ENABLE_LOG_INFO, SAL_DETAIL_LOG_LEVEL_INFO, area, \
- SAL_WHERE, __VA_ARGS__)
-
-#define SAL_INFO_IF(condition, area, ...) \
- SAL_DETAIL_LOG_FORMAT( \
- SAL_DETAIL_ENABLE_LOG_INFO && (condition), SAL_DETAIL_LOG_LEVEL_INFO, \
- area, SAL_WHERE, __VA_ARGS__)
-
-#define SAL_WARN(area, ...) \
- SAL_DETAIL_LOG_FORMAT( \
- SAL_DETAIL_ENABLE_LOG_WARN, SAL_DETAIL_LOG_LEVEL_WARN, area, \
- SAL_WHERE, __VA_ARGS__)
-
-#define SAL_WARN_IF(condition, area, ...) \
- SAL_DETAIL_LOG_FORMAT( \
- SAL_DETAIL_ENABLE_LOG_WARN && (condition), SAL_DETAIL_LOG_LEVEL_WARN, \
- area, SAL_WHERE, __VA_ARGS__)
-
-#if defined __cplusplus
-
-#define SAL_INFO_S(area, stream) \
+#define SAL_INFO(area, stream) \
SAL_DETAIL_LOG_STREAM( \
SAL_DETAIL_ENABLE_LOG_INFO, ::SAL_DETAIL_LOG_LEVEL_INFO, area, \
SAL_WHERE, stream)
-#define SAL_INFO_IF_S(condition, area, stream) \
+#define SAL_INFO_IF(condition, area, stream) \
SAL_DETAIL_LOG_STREAM( \
SAL_DETAIL_ENABLE_LOG_INFO && (condition), \
::SAL_DETAIL_LOG_LEVEL_INFO, area, SAL_WHERE, stream)
-#define SAL_WARN_S(area, stream) \
+#define SAL_WARN(area, stream) \
SAL_DETAIL_LOG_STREAM( \
SAL_DETAIL_ENABLE_LOG_WARN, ::SAL_DETAIL_LOG_LEVEL_WARN, area, \
SAL_WHERE, stream)
-#define SAL_WARN_IF_S(condition, area, stream) \
+#define SAL_WARN_IF(condition, area, stream) \
SAL_DETAIL_LOG_STREAM( \
SAL_DETAIL_ENABLE_LOG_WARN && (condition), \
::SAL_DETAIL_LOG_LEVEL_WARN, area, SAL_WHERE, stream)
-#endif
#endif
diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
index be45cf629b81..a43964436842 100644
--- a/sal/osl/all/log.cxx
+++ b/sal/osl/all/log.cxx
@@ -42,7 +42,8 @@
#include "osl/thread.hxx"
#include "rtl/string.h"
-#include "sal/log.h"
+#include "sal/detail/log.h"
+#include "sal/log.hxx"
#include "sal/types.h"
#include "logformat.hxx"
diff --git a/sal/osl/all/logformat.hxx b/sal/osl/all/logformat.hxx
index f4589a7b9f94..bb6ea4cc6bdd 100644
--- a/sal/osl/all/logformat.hxx
+++ b/sal/osl/all/logformat.hxx
@@ -34,7 +34,7 @@
#include <cstdarg>
-#include "sal/log.h"
+#include "sal/detail/log.h"
namespace osl { namespace detail {
diff --git a/sal/osl/all/trace.cxx b/sal/osl/all/trace.cxx
index 835704779452..8fccb44b68d0 100644
--- a/sal/osl/all/trace.cxx
+++ b/sal/osl/all/trace.cxx
@@ -33,7 +33,8 @@
#include <cstdarg>
#include "osl/diagnose.h"
-#include "sal/log.h"
+#include "sal/detail/log.h"
+#include "sal/log.hxx"
#include "logformat.hxx"
diff --git a/sal/osl/unx/conditn.c b/sal/osl/unx/conditn.cxx
index d7ab7131938c..c6417bfb2f7a 100644
--- a/sal/osl/unx/conditn.c
+++ b/sal/osl/unx/conditn.cxx
@@ -31,7 +31,7 @@
#include <assert.h>
#include "system.h"
-#include <sal/log.h>
+#include <sal/log.hxx>
#include <sal/types.h>
#include <osl/conditn.h>
@@ -69,8 +69,9 @@ oslCondition SAL_CALL osl_createCondition()
if ( nRet != 0 )
{
SAL_WARN(
- "sal", "pthread_cond_init failed, errno %d, \"%s\"", nRet,
- strerror(nRet));
+ "sal",
+ "pthread_cond_init failed, errno " << nRet << ", \""
+ << strerror(nRet) << '"');
free(pCond);
return 0;
@@ -80,13 +81,15 @@ oslCondition SAL_CALL osl_createCondition()
if ( nRet != 0 )
{
SAL_WARN(
- "sal", "pthread_mutex_init failed, errno %d, \"%s\"", nRet,
- strerror(nRet));
+ "sal",
+ "pthread_mutex_init failed, errno " << nRet << ", \""
+ << strerror(nRet) << '"');
nRet = pthread_cond_destroy(&pCond->m_Condition);
SAL_WARN_IF(
- nRet != 0, "sal", "pthread_cond_destroy failed, errno %d, \"%s\"",
- nRet, strerror(nRet));
+ nRet != 0, "sal",
+ "pthread_cond_destroy failed, errno " << nRet << ", \""
+ << strerror(nRet) << '"');
free(pCond);
pCond = 0;
@@ -109,12 +112,14 @@ void SAL_CALL osl_destroyCondition(oslCondition Condition)
nRet = pthread_cond_destroy(&pCond->m_Condition);
SAL_WARN_IF(
- nRet != 0, "sal", "pthread_cond_destroy failed, errno %d, \"%s\"",
- nRet, strerror(nRet));
+ nRet != 0, "sal",
+ "pthread_cond_destroy failed, errno " << nRet << ", \""
+ << strerror(nRet) << '"');
nRet = pthread_mutex_destroy(&pCond->m_Lock);
SAL_WARN_IF(
- nRet != 0, "sal", "pthread_mutex_destroy failed, errno %d, \"%s\"",
- nRet, strerror(nRet));
+ nRet != 0, "sal",
+ "pthread_mutex_destroy failed, errno " << nRet << ", \""
+ << strerror(nRet) << '"');
free(Condition);
}
@@ -142,8 +147,9 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition)
if ( nRet != 0 )
{
SAL_WARN(
- "sal", "pthread_mutex_lock failed, errno %d, \"%s\"", nRet,
- strerror(nRet));
+ "sal",
+ "pthread_mutex_lock failed, errno " << nRet << ", \""
+ << strerror(nRet) << '"');
return sal_False;
}
@@ -152,8 +158,9 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition)
if ( nRet != 0 )
{
SAL_WARN(
- "sal", "pthread_cond_broadcast failed, errno %d, \"%s\"", nRet,
- strerror(nRet));
+ "sal",
+ "pthread_cond_broadcast failed, errno " << nRet << ", \""
+ << strerror(nRet) << '"');
return sal_False;
}
@@ -161,8 +168,9 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition)
if ( nRet != 0 )
{
SAL_WARN(
- "sal", "pthread_mutex_unlock failed, errno %d, \"%s\"", nRet,
- strerror(nRet));
+ "sal",
+ "pthread_mutex_unlock failed, errno " << nRet << ", \""
+ << strerror(nRet) << '"');
return sal_False;
}
@@ -191,8 +199,9 @@ sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition)
if ( nRet != 0 )
{
SAL_WARN(
- "sal", "pthread_mutex_lock failed, errno %d, \"%s\"", nRet,
- strerror(nRet));
+ "sal",
+ "pthread_mutex_lock failed, errno " << nRet << ", \""
+ << strerror(nRet) << '"');
return sal_False;
}
@@ -202,8 +211,8 @@ sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition)
if ( nRet != 0 )
{
SAL_WARN(
- "sal", "pthread_mutex_unlock failed, errno %d, \"%s\"", nRet,
- strerror(nRet));
+ "sal", "pthread_mutex_unlock failed, errno " << nRet <<", \""
+ << strerror(nRet) << '"');
return sal_False;
}
@@ -231,8 +240,8 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
if ( nRet != 0 )
{
SAL_WARN(
- "sal", "pthread_mutex_lock failed, errno %d, \"%s\"", nRet,
- strerror(nRet));
+ "sal", "pthread_mutex_lock failed, errno " << nRet <<", \""
+ << strerror(nRet) << '"');
return osl_cond_result_error;
}
@@ -261,8 +270,8 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
nRet = pthread_mutex_unlock(&pCond->m_Lock);
SAL_WARN_IF(
nRet != 0, "sal",
- "pthread_mutex_unlock failed, errno %d, \"%s\"",
- nRet, strerror(nRet));
+ "pthread_mutex_unlock failed, errno " << nRet
+ << ", \"" << strerror(nRet) << '"');
return Result;
}
@@ -272,8 +281,8 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
nRet = pthread_mutex_unlock(&pCond->m_Lock);
SAL_WARN_IF(
nRet != 0, "sal",
- "pthread_mutex_unlock failed, errno %d, \"%s\"",
- nRet, strerror(nRet));
+ "pthread_mutex_unlock failed, errno " << nRet
+ << ", \"" << strerror(nRet) << '"');
return Result;
}
}
@@ -289,14 +298,15 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
if ( nRet != 0 )
{
SAL_WARN(
- "sal", "pthread_cond_wait failed, errno %d, \"%s\"", nRet,
- strerror(nRet));
+ "sal",
+ "pthread_cond_wait failed, errno " << nRet << ", \""
+ << strerror(nRet) << '"');
Result = osl_cond_result_error;
nRet = pthread_mutex_unlock(&pCond->m_Lock);
SAL_WARN_IF(
nRet != 0, "sal",
- "pthread_mutex_unlock failed, errno %d, \"%s\"", nRet,
- strerror(nRet));
+ "pthread_mutex_unlock failed, errno " << nRet << ", \""
+ << strerror(nRet) << '"');
return Result;
}
@@ -305,8 +315,9 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
nRet = pthread_mutex_unlock(&pCond->m_Lock);
SAL_WARN_IF(
- nRet != 0, "sal", "pthread_mutex_unlock failed, errno %d, \"%s\"", nRet,
- strerror(nRet));
+ nRet != 0, "sal",
+ "pthread_mutex_unlock failed, errno " << nRet << ", \""
+ << strerror(nRet) << '"');
return Result;
}
@@ -330,15 +341,17 @@ sal_Bool SAL_CALL osl_checkCondition(oslCondition Condition)
nRet = pthread_mutex_lock(&pCond->m_Lock);
SAL_WARN_IF(
- nRet != 0, "sal", "pthread_mutex_lock failed, errno %d, \"%s\"", nRet,
- strerror(nRet));
+ nRet != 0, "sal",
+ "pthread_mutex_lock failed, errno " << nRet << ", \"" << strerror(nRet)
+ << '"');
State = pCond->m_State;
nRet = pthread_mutex_unlock(&pCond->m_Lock);
SAL_WARN_IF(
- nRet != 0, "sal", "pthread_mutex_unlock failed, errno %d, \"%s\"", nRet,
- strerror(nRet));
+ nRet != 0, "sal",
+ "pthread_mutex_unlock failed, errno " << nRet << ", \""
+ << strerror(nRet) << '"');
return State;
}
diff --git a/sal/prj/d.lst b/sal/prj/d.lst
index 5023c576b334..c7f93ed06309 100644
--- a/sal/prj/d.lst
+++ b/sal/prj/d.lst
@@ -1,6 +1,7 @@
mkdir: %_DEST%\bin\cppunit
mkdir: %_DEST%\inc\cppunittester
mkdir: %_DEST%\inc\sal
+mkdir: %_DEST%\inc\sal\detail
mkdir: %_DEST%\inc\osl
mkdir: %_DEST%\inc\rtl
mkdir: %_DEST%\inc\systools
@@ -9,7 +10,9 @@ mkdir: %_DEST%\inc\systools\win32
..\inc\cppunittester\protectorfactory.hxx %_DEST%\inc\protectorfactory.hxx
..\%__SRC%\inc\rtlbootstrap.mk %_DEST%\inc\rtlbootstrap.mk
..\inc\sal\*.h %_DEST%\inc\sal\*.h
+..\inc\sal\log.hxx %_DEST%\inc\sal\log.hxx
..\inc\sal\precppunit.hxx %_DEST%\inc\sal\precppunit.hxx
+..\inc\sal\detail\log.h %_DEST%\inc\sal\detail\log.h
..\%__SRC%\inc\sal\typesizes.h %_DEST%\inc\sal\typesizes.h
..\inc\osl\*.h %_DEST%\inc\osl\*.h
..\inc\osl\*.hxx %_DEST%\inc\osl\*.hxx
diff --git a/sal/rtl/source/logfile.cxx b/sal/rtl/source/logfile.cxx
index c5858c1747b8..a9bf40b5a0ee 100644
--- a/sal/rtl/source/logfile.cxx
+++ b/sal/rtl/source/logfile.cxx
@@ -44,7 +44,7 @@
#include <rtl/ustrbuf.hxx>
#include <rtl/alloc.h>
#include <rtl/instance.hxx>
-#include <sal/log.h>
+#include <sal/log.hxx>
#include "osl/thread.h"
#include <algorithm>
@@ -109,7 +109,7 @@ OUString getFileUrl( const OUString &name )
if ( osl_getFileURLFromSystemPath( name.pData, &aRet.pData )
!= osl_File_E_None )
{
- SAL_WARN_S(
+ SAL_WARN(
"sal", "osl_getFileURLFromSystemPath failed for \"" << name << '"');
}
@@ -185,7 +185,7 @@ void init() {
}
else
{
- SAL_WARN_S(
+ SAL_WARN(
"sal",
"Couldn't open logfile " << o << '(' << e << ')');
}