summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2011-11-22 09:34:46 +0100
committerStephan Bergmann <sbergman@redhat.com>2011-11-22 09:41:47 +0100
commit70a6b9ffbd676a1384433a86205d2cd4f2d4f4b1 (patch)
treeffb31ef817b5f2037cf7c332da422b9179d613d5
parentf2972242673cc9608960e9ca70e82766be5275e3 (diff)
New sal/log.h obsoletes osl/diagnose.h and tools/debug.hxx.
* New SAL_INFO..., SAL_WARN... macros. * New SAL_STREAM supersedes OSL_FORMAT. * oustringostreaminserter.hxx moved from unotest to rtl (and always UTF-8 now). * TODO to enable GCC __attribute__((format)) in sal/log.h (requires call-site cleanup). * Further functionality in tools/debug.hxx (DBG_MEMTEST, DBG_CTOR, etc.) not yet addressed. * Some replacements tools String -> rtl::OUString.
-rw-r--r--avmedia/source/viewer/mediawindowbase_impl.cxx14
-rw-r--r--basic/inc/basic/sbxcore.hxx3
-rw-r--r--basic/source/app/app.cxx17
-rw-r--r--basic/source/sbx/sbxbase.cxx25
-rw-r--r--basic/source/uno/namecont.cxx208
-rw-r--r--canvas/inc/canvas/verbosetrace.hxx11
-rw-r--r--cppu/qa/cppumaker/test_cppumaker.cxx15
-rw-r--r--cppu/qa/test_unotype.cxx15
-rw-r--r--desktop/source/deployment/registry/dp_backend.cxx18
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/diagnostics.h94
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/util.cxx13
-rw-r--r--sal/inc/osl/diagnose.h79
-rw-r--r--sal/inc/osl/diagnose.hxx27
-rw-r--r--sal/inc/osl/thread.hxx10
-rw-r--r--sal/inc/rtl/oustringostreaminserter.hxx (renamed from unotest/inc/unotest/oustringostreaminserter.hxx)20
-rw-r--r--sal/inc/rtl/strbuf.hxx11
-rw-r--r--sal/inc/rtl/string.hxx19
-rw-r--r--sal/inc/rtl/ustrbuf.hxx15
-rw-r--r--sal/inc/rtl/ustring.hxx29
-rw-r--r--sal/inc/sal/log.h305
-rw-r--r--sal/osl/all/log.cxx199
-rw-r--r--sal/osl/all/logformat.hxx49
-rw-r--r--sal/osl/all/makefile.mk8
-rw-r--r--sal/osl/all/printtrace.cxx68
-rw-r--r--sal/osl/all/trace.cxx (renamed from sal/osl/all/formatstring.cxx)37
-rw-r--r--sal/osl/inc/printtrace.h49
-rw-r--r--sal/osl/unx/conditn.c137
-rw-r--r--sal/osl/unx/diagnose.c13
-rw-r--r--sal/osl/w32/diagnose.c21
-rw-r--r--sal/rtl/source/logfile.cxx9
-rwxr-xr-xsal/util/sal.map3
-rw-r--r--sfx2/inc/sfx2/objface.hxx4
-rw-r--r--sfx2/source/appl/module.cxx12
-rw-r--r--sfx2/source/control/bindings.cxx56
-rw-r--r--sfx2/source/control/dispatch.cxx37
-rw-r--r--sfx2/source/control/shell.cxx28
-rw-r--r--smoketestoo_native/smoketest.cxx2
-rw-r--r--solenv/bin/addsym.awk7
-rw-r--r--solenv/gbuild/gbuild.mk8
-rw-r--r--solenv/inc/settings.mk3
-rw-r--r--svl/source/inc/poolio.hxx9
-rw-r--r--svl/source/items/itempool.cxx2
-rw-r--r--svl/source/items/poolio.cxx9
-rw-r--r--svl/source/items/whassert.hxx25
-rw-r--r--sw/source/ui/docvw/srcedtw.cxx21
-rw-r--r--tools/inc/tools/debug.hxx151
-rw-r--r--tools/qa/cppunit/test_reversemap.cxx2
-rw-r--r--tools/source/debug/debug.cxx110
-rw-r--r--tools/source/rc/resmgr.cxx8
-rw-r--r--unotest/prj/d.lst1
-rwxr-xr-xvcl/source/app/dbggui.cxx26
51 files changed, 1077 insertions, 985 deletions
diff --git a/avmedia/source/viewer/mediawindowbase_impl.cxx b/avmedia/source/viewer/mediawindowbase_impl.cxx
index 77ec02b5846c..3c883a18d872 100644
--- a/avmedia/source/viewer/mediawindowbase_impl.cxx
+++ b/avmedia/source/viewer/mediawindowbase_impl.cxx
@@ -30,6 +30,8 @@
#include <avmedia/mediaitem.hxx>
#include "mediamisc.hxx"
#include "mediawindow.hrc"
+#include <rtl/oustringostreaminserter.hxx>
+#include <sal/log.h>
#include <tools/urlobj.hxx>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -81,14 +83,18 @@ uno::Reference< media::XPlayer > MediaWindowBaseImpl::createPlayer( const ::rtl:
xManager->createPlayer( rURL ), uno::UNO_QUERY );
}
else
- OSL_FAIL( "failed to create media player service " AVMEDIA_MANAGER_SERVICE_NAME );
+ SAL_WARN_S(
+ "avmedia",
+ ("failed to create media player service "
+ AVMEDIA_MANAGER_SERVICE_NAME));
}
catch( const uno::Exception &e )
{
(void)e;
- OSL_FAIL( OSL_FORMAT( "couldn't create media player '%s', exception '%s'",
- AVMEDIA_MANAGER_SERVICE_NAME,
- rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() ) );
+ SAL_WARN_S(
+ "avmedia",
+ "couldn't create media player " AVMEDIA_MANAGER_SERVICE_NAME
+ ", exception '" << e.Message << '\'');
}
}
diff --git a/basic/inc/basic/sbxcore.hxx b/basic/inc/basic/sbxcore.hxx
index a4abca6d4649..1969adf0cc1c 100644
--- a/basic/inc/basic/sbxcore.hxx
+++ b/basic/inc/basic/sbxcore.hxx
@@ -39,6 +39,7 @@
class SvStream;
class String;
class UniString;
+namespace rtl { class OUString; }
// The following Macro defines four (five) necessary methods within a
// SBX object. LoadPrivateData() and StorePrivateData() must be implemented.
@@ -133,7 +134,7 @@ public:
static void RemoveFactory( SbxFactory* );
static SbxBase* Create( sal_uInt16, sal_uInt32=SBXCR_SBX );
- static SbxObject* CreateObject( const String& );
+ static SbxObject* CreateObject( const rtl::OUString& );
};
#ifndef SBX_BASE_DECL_DEFINED
diff --git a/basic/source/app/app.cxx b/basic/source/app/app.cxx
index 72f3ab0cd5e3..e0175696726e 100644
--- a/basic/source/app/app.cxx
+++ b/basic/source/app/app.cxx
@@ -70,7 +70,9 @@
#include <ucbhelper/content.hxx>
#include <unotools/syslocale.hxx>
+#include <rtl/oustringostreaminserter.hxx>
#include <rtl/strbuf.hxx>
+#include <sal/log.h>
using namespace comphelper;
using namespace cppu;
@@ -241,8 +243,9 @@ int BasicApp::Main( )
DbgSetPrintTestTool( DBG_TestToolDebugMessageFilter );
DBG_INSTOUTERROR( DBG_OUT_TESTTOOL );
- if ( osl_setDebugMessageFunc( osl_TestToolDebugMessageFilter ) )
- OSL_FAIL("osl_setDebugMessageFunc returns non NULL pointer");
+ SAL_WARN_IF(
+ osl_setDebugMessageFunc(osl_TestToolDebugMessageFilter), "basic",
+ "osl_setDebugMessageFunc returns non NULL pointer");
#endif
ResMgr::SetReadStringHook( ReplaceStringHookProc );
@@ -1849,12 +1852,10 @@ String BasicFrame::GenRealString( const String &aResString )
}
else
{
- OSL_FAIL(
- OSL_FORMAT(
- "Unknown replacement in String: %s",
- rtl::OUStringToOString(
- aResult.Copy(nStart, nEnd - nStart),
- RTL_TEXTENCODING_UTF8).getStr()));
+ SAL_WARN_S(
+ "basic",
+ "Unknown replacement in String: "
+ << rtl::OUString(aResult.Copy(nStart, nEnd - nStart)));
nStartPos = nStartPos + StartKenn.Len();
}
}
diff --git a/basic/source/sbx/sbxbase.cxx b/basic/source/sbx/sbxbase.cxx
index 1520c437638f..fa831ab36bd6 100644
--- a/basic/source/sbx/sbxbase.cxx
+++ b/basic/source/sbx/sbxbase.cxx
@@ -38,7 +38,8 @@
#include <basic/sbxbase.hxx>
#include <rtl/instance.hxx>
-#include <rtl/strbuf.hxx>
+#include <rtl/oustringostreaminserter.hxx>
+#include <sal/log.h>
// AppData-Structure for SBX:
@@ -212,19 +213,11 @@ SbxBase* SbxBase::Create( sal_uInt16 nSbxId, sal_uInt32 nCreator )
if( pNew )
break;
}
-#ifdef DBG_UTIL
- if( !pNew )
- {
- rtl::OStringBuffer aMsg(
- RTL_CONSTASCII_STRINGPARAM("SBX: Keine Factory fuer SBX-ID "));
- aMsg.append(static_cast<sal_Int32>(nSbxId));
- DbgError(aMsg.getStr());
- }
-#endif
+ SAL_WARN_IF_S(!pNew, "basic", "No factory for SBX ID " << nSbxId);
return pNew;
}
-SbxObject* SbxBase::CreateObject( const XubString& rClass )
+SbxObject* SbxBase::CreateObject( const rtl::OUString& rClass )
{
SbxAppData& r = GetSbxData_Impl();
SbxObject* pNew = NULL;
@@ -234,15 +227,7 @@ SbxObject* SbxBase::CreateObject( const XubString& rClass )
if( pNew )
break;
}
-#ifdef DBG_UTIL
- if( !pNew )
- {
- ByteString aMsg( "SBX: Keine Factory fuer Objektklasse " );
- ByteString aClassStr( (const UniString&)rClass, RTL_TEXTENCODING_ASCII_US );
- aMsg += aClassStr;
- DbgError( (const char*)aMsg.GetBuffer() );
- }
-#endif
+ SAL_WARN_IF_S(!pNew, "basic", "No factory for object class " << rClass);
return pNew;
}
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index 988c5c9c67eb..f7abc391f895 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -37,9 +37,10 @@
#include <osl/mutex.hxx>
#include <tools/errinf.hxx>
#include <osl/mutex.hxx>
-#include <osl/diagnose.h>
+#include <rtl/oustringostreaminserter.hxx>
#include <rtl/uri.hxx>
#include <rtl/strbuf.hxx>
+#include <sal/log.h>
#include <comphelper/processfactory.hxx>
#include <comphelper/anytostring.hxx>
@@ -382,24 +383,18 @@ SfxLibraryContainer::SfxLibraryContainer( void )
DBG_CTOR( SfxLibraryContainer, NULL );
mxMSF = comphelper::getProcessServiceFactory();
- if( !mxMSF.is() )
- {
- OSL_FAIL( "couldn't get ProcessServiceFactory" );
- }
+ SAL_WARN_IF(!mxMSF.is(), "basic", "couldn't get ProcessServiceFactory");
mxSFI = Reference< XSimpleFileAccess >( mxMSF->createInstance
( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess")) ), UNO_QUERY );
- if( !mxSFI.is() )
- {
- OSL_FAIL( "couldn't create SimpleFileAccess component" );
- }
+ SAL_WARN_IF(
+ !mxSFI.is(), "basic", "couldn't create SimpleFileAccess component");
mxStringSubstitution = Reference< XStringSubstitution >( mxMSF->createInstance
( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.PathSubstitution")) ), UNO_QUERY );
- if( !mxStringSubstitution.is() )
- {
- OSL_FAIL( "couldn't create PathSubstitution component" );
- }
+ SAL_WARN_IF(
+ !mxStringSubstitution.is(), "basic",
+ "couldn't create PathSubstitution component");
}
SfxLibraryContainer::~SfxLibraryContainer()
@@ -432,7 +427,10 @@ BasicManager* SfxLibraryContainer::getBasicManager( void )
return mpBasMgr;
Reference< XModel > xDocument( mxOwnerDocument.get(), UNO_QUERY );
- OSL_ENSURE( xDocument.is(), "SfxLibraryContainer::getBasicManager: cannot obtain a BasicManager without document!" );
+ SAL_WARN_IF(
+ !xDocument.is(), "basic",
+ ("SfxLibraryContainer::getBasicManager: cannot obtain a BasicManager"
+ " without document!"));
if ( xDocument.is() )
mpBasMgr = BasicManagerRepository::getDocumentBasicManager( xDocument );
@@ -673,7 +671,7 @@ sal_Bool SfxLibraryContainer::init_Impl(
OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Parser") ) ), UNO_QUERY );
if( !xParser.is() )
{
- OSL_FAIL( "couldn't create sax parser component" );
+ SAL_WARN("basic", "couldn't create sax parser component");
return sal_False;
}
@@ -697,8 +695,9 @@ sal_Bool SfxLibraryContainer::init_Impl(
{
if( bStorage )
{
- OSL_ENSURE( meInitMode == DEFAULT || meInitMode == OFFICE_DOCUMENT,
- "### Wrong InitMode for document\n" );
+ SAL_WARN_IF(
+ meInitMode != DEFAULT && meInitMode != OFFICE_DOCUMENT, "basic",
+ "Wrong InitMode for document");
try
{
uno::Reference< io::XStream > xStream;
@@ -824,13 +823,13 @@ sal_Bool SfxLibraryContainer::init_Impl(
catch ( xml::sax::SAXException& e )
{
(void) e; // avoid warning
- OSL_FAIL( OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
+ SAL_WARN_S("basic", e.Message);
return sal_False;
}
catch ( io::IOException& e )
{
(void) e; // avoid warning
- OSL_FAIL( OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
+ SAL_WARN_S("basic", e.Message);
return sal_False;
}
@@ -918,16 +917,11 @@ sal_Bool SfxLibraryContainer::init_Impl(
{
#if OSL_DEBUG_LEVEL > 0
Any aError( ::cppu::getCaughtException() );
- OSL_FAIL(
- OSL_FORMAT(
- ("couldn't open sub storage for library"
- " \"%s\". Exception: %s"),
- (rtl::OUStringToOString(
- rLib.aName, RTL_TEXTENCODING_UTF8).
- getStr()),
- rtl::OUStringToOString(
- comphelper::anyToString(aError),
- RTL_TEXTENCODING_UTF8).getStr()));
+ SAL_WARN_S(
+ "basic",
+ "couldn't open sub storage for library \""
+ << rLib.aName << "\". Exception: "
+ << comphelper::anyToString(aError));
#endif
}
}
@@ -937,11 +931,10 @@ sal_Bool SfxLibraryContainer::init_Impl(
{
OUString aIndexFileName;
sal_Bool bLoaded = implLoadLibraryIndexFile( pImplLib, rLib, xLibraryStor, aIndexFileName );
- if( bLoaded && aLibName != rLib.aName )
- {
- OSL_FAIL( "Different library names in library"
- " container and library info files!" );
- }
+ SAL_WARN_IF(
+ bLoaded && aLibName != rLib.aName, "basic",
+ ("Different library names in library container and"
+ " library info files!"));
if( GbMigrationSuppressErrors && !bLoaded )
removeLibrary( aLibName );
}
@@ -989,7 +982,7 @@ sal_Bool SfxLibraryContainer::init_Impl(
catch(const uno::Exception& )
{
// TODO: error handling?
- OSL_FAIL( "Cannot access extensions!" );
+ SAL_WARN("basic", "Cannot access extensions!");
}
}
@@ -1204,7 +1197,7 @@ sal_Bool SfxLibraryContainer::init_Impl(
// #i93163
if( bCleanUp )
{
- OSL_FAIL( "Upgrade of Basic installation failed somehow" );
+ SAL_WARN("basic", "Upgrade of Basic installation failed somehow");
static char strErrorSavFolderName[] = "__basic_80_err";
INetURLObject aPrevUserBasicInetObj_Err( aUserBasicInetObj );
@@ -1414,11 +1407,9 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
if( !isLibraryElementValid( pLib->getByName( aElementName ) ) )
{
- OSL_FAIL(
- OSL_FORMAT(
- "invalid library element \"%s\"",
- rtl::OUStringToOString(
- aElementName, RTL_TEXTENCODING_UTF8).getStr()));
+ SAL_WARN_S(
+ "basic",
+ "invalid library element \"" << aElementName << '"');
continue;
}
try {
@@ -1431,7 +1422,9 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
OUString aMime( RTL_CONSTASCII_USTRINGPARAM("text/xml") );
uno::Reference< beans::XPropertySet > xProps( xElementStream, uno::UNO_QUERY );
- OSL_ENSURE( xProps.is(), "The StorageStream must implement XPropertySet interface!\n" );
+ SAL_WARN_IF(
+ !xProps.is(), "basic",
+ "The StorageStream must implement XPropertySet interface!");
//if ( !xProps.is() ) //TODO
if ( xProps.is() )
@@ -1449,7 +1442,7 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
}
catch(const uno::Exception& )
{
- OSL_FAIL( "Problem during storing of library!" );
+ SAL_WARN("basic", "Problem during storing of library!");
// TODO: error handling?
}
}
@@ -1496,11 +1489,9 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
if( !isLibraryElementValid( pLib->getByName( aElementName ) ) )
{
- OSL_FAIL(
- OSL_FORMAT(
- "invalid library element \"%s\"",
- rtl::OUStringToOString(
- aElementName, RTL_TEXTENCODING_UTF8).getStr()));
+ SAL_WARN_S(
+ "basic",
+ "invalid library element \"" << aElementName << '"');
continue;
}
@@ -1552,7 +1543,7 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer") ) ), UNO_QUERY );
if( !xHandler.is() )
{
- OSL_FAIL( "couldn't create sax-writer component" );
+ SAL_WARN("basic", "couldn't create sax-writer component");
return;
}
@@ -1569,7 +1560,7 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
try {
xInfoStream = xStorage->openStreamElement( aStreamName, embed::ElementModes::READWRITE );
- OSL_ENSURE( xInfoStream.is(), "No stream!\n" );
+ SAL_WARN_IF(!xInfoStream.is(), "basic", "No stream!");
uno::Reference< beans::XPropertySet > xProps( xInfoStream, uno::UNO_QUERY );
// throw uno::RuntimeException(); // TODO
@@ -1588,7 +1579,7 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
}
catch(const uno::Exception& )
{
- OSL_FAIL( "Problem during storing of library index file!" );
+ SAL_WARN("basic", "Problem during storing of library index file!");
// TODO: error handling?
}
}
@@ -1637,7 +1628,7 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
}
if( !xOut.is() )
{
- OSL_FAIL( "couldn't open output stream" );
+ SAL_WARN("basic", "couldn't open output stream");
return;
}
@@ -1655,7 +1646,7 @@ sal_Bool SfxLibraryContainer::implLoadLibraryIndexFile( SfxLibrary* pLib,
OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Parser") ) ), UNO_QUERY );
if( !xParser.is() )
{
- OSL_FAIL( "couldn't create sax parser component" );
+ SAL_WARN("basic", "couldn't create sax parser component");
return sal_False;
}
@@ -1727,7 +1718,7 @@ sal_Bool SfxLibraryContainer::implLoadLibraryIndexFile( SfxLibrary* pLib,
}
catch(const Exception& )
{
- OSL_FAIL( "Parsing error" );
+ SAL_WARN("basic", "Parsing error");
SfxErrorContext aEc( ERRCTX_SFX_LOADBASIC, aLibInfoPath );
sal_uIntPtr nErrorCode = ERRCODE_IO_GENERAL;
ErrorHandler::HandleError( nErrorCode );
@@ -1915,15 +1906,11 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
{
#if OSL_DEBUG_LEVEL > 0
Any aError( ::cppu::getCaughtException() );
- OSL_FAIL(
- OSL_FORMAT(
- ("couldn't create sub storage for library"
- " \"%s\". Exception: %s"),
- rtl::OUStringToOString(
- rLib.aName, RTL_TEXTENCODING_UTF8).getStr(),
- rtl::OUStringToOString(
- comphelper::anyToString(aError),
- RTL_TEXTENCODING_UTF8).getStr()));
+ SAL_WARN_S(
+ "basic",
+ "couldn't create sub storage for library \""
+ << rLib.aName << "\". Exception: "
+ << comphelper::anyToString(aError));
#endif
return;
}
@@ -1967,7 +1954,10 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
// then we need to clean up the temporary storage we used for this
if ( bInplaceStorage && sTempTargetStorName.getLength() )
{
- OSL_ENSURE( xSourceLibrariesStor.is(), "SfxLibrariesContainer::storeLibraries_impl: unexpected: we should have a source storage here!" );
+ SAL_WARN_IF(
+ !xSourceLibrariesStor.is(), "basic",
+ ("SfxLibrariesContainer::storeLibraries_impl: unexpected: we should"
+ " have a source storage here!"));
try
{
// for this, we first remove everything from the source storage, then copy the complete content
@@ -2028,7 +2018,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer") ) ), UNO_QUERY );
if( !xHandler.is() )
{
- OSL_FAIL( "couldn't create sax-writer component" );
+ SAL_WARN("basic", "couldn't create sax-writer component");
return;
}
@@ -2043,7 +2033,9 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
try {
xInfoStream = xTargetLibrariesStor->openStreamElement( aStreamName, embed::ElementModes::READWRITE );
uno::Reference< beans::XPropertySet > xProps( xInfoStream, uno::UNO_QUERY );
- OSL_ENSURE ( xProps.is(), "The stream must implement XPropertySet!\n" );
+ SAL_WARN_IF(
+ !xProps.is(), "basic",
+ "The stream must implement XPropertySet!");
if ( !xProps.is() )
throw uno::RuntimeException();
@@ -2088,7 +2080,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
}
if( !xOut.is() )
{
- OSL_FAIL( "couldn't open output stream" );
+ SAL_WARN("basic", "couldn't open output stream");
return;
}
@@ -2101,7 +2093,9 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
if ( bStorage )
{
uno::Reference< embed::XTransactedObject > xTransact( xTargetLibrariesStor, uno::UNO_QUERY );
- OSL_ENSURE( xTransact.is(), "The storage must implement XTransactedObject!\n" );
+ SAL_WARN_IF(
+ !xTransact.is(), "basic",
+ "The storage must implement XTransactedObject!");
if ( !xTransact.is() )
throw uno::RuntimeException();
@@ -2110,7 +2104,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
}
catch(const uno::Exception& )
{
- OSL_FAIL( "Problem during storing of libraries!" );
+ SAL_WARN("basic", "Problem during storing of libraries!");
sal_uIntPtr nErrorCode = ERRCODE_IO_GENERAL;
ErrorHandler::HandleError( nErrorCode );
}
@@ -2326,12 +2320,18 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name )
{
try {
xLibrariesStor = mxStorage->openStorageElement( maLibrariesDir, embed::ElementModes::READ );
- OSL_ENSURE( xLibrariesStor.is(), "The method must either throw exception or return a storage!\n" );
+ SAL_WARN_IF(
+ !xLibrariesStor.is(), "basic",
+ ("The method must either throw exception or return a"
+ " storage!"));
if ( !xLibrariesStor.is() )
throw uno::RuntimeException();
xLibraryStor = xLibrariesStor->openStorageElement( Name, embed::ElementModes::READ );
- OSL_ENSURE( xLibraryStor.is(), "The method must either throw exception or return a storage!\n" );
+ SAL_WARN_IF(
+ !xLibraryStor.is(), "basic",
+ ("The method must either throw exception or return a"
+ " storage!"));
if ( !xLibrariesStor.is() )
throw uno::RuntimeException();
}
@@ -2339,15 +2339,11 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name )
{
#if OSL_DEBUG_LEVEL > 0
Any aError( ::cppu::getCaughtException() );
- OSL_FAIL(
- OSL_FORMAT(
- ("couldn't open sub storage for library \"%s\"."
- " Exception: %s"),
- (rtl::OUStringToOString(Name, RTL_TEXTENCODING_UTF8).
- getStr()),
- rtl::OUStringToOString(
- comphelper::anyToString(aError),
- RTL_TEXTENCODING_UTF8).getStr()));
+ SAL_WARN_S(
+ "basic",
+ "couldn't open sub storage for library \"" << Name
+ << "\". Exception: "
+ << comphelper::anyToString(aError));
#endif
return;
}
@@ -2392,12 +2388,10 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name )
if ( !xInStream.is() )
{
- OSL_FAIL(
- OSL_FORMAT(
- ("couldn't open library element stream - attempted"
- " to open library \"%s\""),
- rtl::OUStringToOString(
- Name, RTL_TEXTENCODING_UTF8).getStr()));
+ SAL_WARN_S(
+ "basic",
+ "couldn't open library element stream - attempted to"
+ " open library \"" << Name << '"');
return;
}
}
@@ -2664,7 +2658,9 @@ void SfxLibraryContainer::_disposing( const EventObject& _rSource )
{
#if OSL_DEBUG_LEVEL > 0
Reference< XModel > xDocument( mxOwnerDocument.get(), UNO_QUERY );
- OSL_ENSURE( ( xDocument == _rSource.Source ) && xDocument.is(), "SfxLibraryContainer::_disposing: where does this come from?" );
+ SAL_WARN_IF(
+ xDocument != _rSource.Source || !xDocument.is(), "basic",
+ "SfxLibraryContainer::_disposing: where does this come from?");
#else
(void)_rSource;
#endif
@@ -2772,14 +2768,13 @@ OUString SfxLibraryContainer::expand_url( const OUString& url )
{
if( !mxMacroExpander.is() )
{
- Reference< XPropertySet > xProps( mxMSF, UNO_QUERY );
- OSL_ASSERT( xProps.is() );
+ Reference< XPropertySet > xProps( mxMSF, UNO_QUERY_THROW );
if( xProps.is() )
{
Reference< XComponentContext > xContext;
xProps->getPropertyValue(
OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= xContext;
- OSL_ASSERT( xContext.is() );
+ SAL_WARN_IF(!xContext.is(), "basic", "no DefaultContext");
if( xContext.is() )
{
Reference< util::XMacroExpander > xExpander;
@@ -3085,7 +3080,9 @@ void SfxLibrary::replaceByName( const OUString& aName, const Any& aElement )
impl_checkReadOnly();
impl_checkLoaded();
- OSL_ENSURE( isLibraryElementValid( aElement ), "SfxLibrary::replaceByName: replacing element is invalid!" );
+ SAL_WARN_IF(
+ !isLibraryElementValid(aElement), "basic",
+ "SfxLibrary::replaceByName: replacing element is invalid!");
maNameContainer.replaceByName( aName, aElement );
implSetModified( sal_True );
@@ -3099,7 +3096,9 @@ void SfxLibrary::insertByName( const OUString& aName, const Any& aElement )
impl_checkReadOnly();
impl_checkLoaded();
- OSL_ENSURE( isLibraryElementValid( aElement ), "SfxLibrary::insertByName: to-be-inserted element is invalid!" );
+ SAL_WARN_IF(
+ !isLibraryElementValid(aElement), "basic",
+ "SfxLibrary::insertByName: to-be-inserted element is invalid!");
maNameContainer.insertByName( aName, aElement );
implSetModified( sal_True );
@@ -3226,13 +3225,12 @@ ScriptExtensionIterator::ScriptExtensionIterator( void )
, m_pScriptSubPackageIterator( NULL )
{
Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
- Reference< XPropertySet > xProps( xFactory, UNO_QUERY );
- OSL_ASSERT( xProps.is() );
+ Reference< XPropertySet > xProps( xFactory, UNO_QUERY_THROW );
if (xProps.is())
{
xProps->getPropertyValue(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= m_xContext;
- OSL_ASSERT( m_xContext.is() );
+ SAL_WARN_IF(!m_xContext.is(), "basic", "no DefaultContext");
}
if( !m_xContext.is() )
{
@@ -3282,7 +3280,10 @@ rtl::OUString ScriptExtensionIterator::nextBasicOrDialogLibrary( bool& rbPureDia
break;
}
case END_REACHED:
- OSL_FAIL( "ScriptExtensionIterator::nextBasicOrDialogLibrary(): Invalid case END_REACHED" );
+ SAL_WARN(
+ "basic",
+ ("ScriptExtensionIterator::nextBasicOrDialogLibrary():"
+ " Invalid case END_REACHED"));
break;
}
}
@@ -3477,7 +3478,10 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextUserScript
{
const Reference< deployment::XPackage >* pUserPackages = m_aUserPackagesSeq.getConstArray();
Reference< deployment::XPackage > xPackage = pUserPackages[ m_iUserPackage ];
- OSL_ENSURE( xPackage.is(), "ScriptExtensionIterator::implGetNextUserScriptPackage(): Invalid package" );
+ SAL_WARN_IF(
+ !xPackage.is(), "basic",
+ ("ScriptExtensionIterator::implGetNextUserScriptPackage():"
+ " Invalid package"));
m_pScriptSubPackageIterator = new ScriptSubPackageIterator( xPackage );
}
@@ -3530,7 +3534,10 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextSharedScri
{
const Reference< deployment::XPackage >* pSharedPackages = m_aSharedPackagesSeq.getConstArray();
Reference< deployment::XPackage > xPackage = pSharedPackages[ m_iSharedPackage ];
- OSL_ENSURE( xPackage.is(), "ScriptExtensionIterator::implGetNextSharedScriptPackage(): Invalid package" );
+ SAL_WARN_IF(
+ !xPackage.is(), "basic",
+ ("ScriptExtensionIterator::implGetNextSharedScriptPackage():"
+ " Invalid package"));
m_pScriptSubPackageIterator = new ScriptSubPackageIterator( xPackage );
}
@@ -3583,7 +3590,10 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextBundledScr
{
const Reference< deployment::XPackage >* pBundledPackages = m_aBundledPackagesSeq.getConstArray();
Reference< deployment::XPackage > xPackage = pBundledPackages[ m_iBundledPackage ];
- OSL_ENSURE( xPackage.is(), "ScriptExtensionIterator::implGetNextBundledScriptPackage(): Invalid package" );
+ SAL_WARN_IF(
+ !xPackage.is(), "basic",
+ ("ScriptExtensionIterator::implGetNextBundledScriptPackage():"
+ " Invalid package"));
m_pScriptSubPackageIterator = new ScriptSubPackageIterator( xPackage );
}
diff --git a/canvas/inc/canvas/verbosetrace.hxx b/canvas/inc/canvas/verbosetrace.hxx
index 0e830825ae41..96e12de23520 100644
--- a/canvas/inc/canvas/verbosetrace.hxx
+++ b/canvas/inc/canvas/verbosetrace.hxx
@@ -29,12 +29,11 @@
#ifndef INCLUDED_CANVAS_VERBOSETRACE_HXX
#define INCLUDED_CANVAS_VERBOSETRACE_HXX
-#if OSL_DEBUG_LEVEL > 2
-/// Wrap OSL_TRACE with a verbosity switch
-#define VERBOSE_TRACE OSL_TRACE
-#else
-#define VERBOSE_TRACE 1 ? ((void)0) : OSL_TRACE
-#endif
+#include "sal/config.h"
+
+#include "sal/log.h"
+
+#define VERBOSE_TRACE(...) SAL_INFO("canvas.level2", __VA_ARGS__)
#endif /* INCLUDED_CANVAS_VERBOSETRACE_HXX */
diff --git a/cppu/qa/cppumaker/test_cppumaker.cxx b/cppu/qa/cppumaker/test_cppumaker.cxx
index 11435e544b9a..bac4b167eca9 100644
--- a/cppu/qa/cppumaker/test_cppumaker.cxx
+++ b/cppu/qa/cppumaker/test_cppumaker.cxx
@@ -372,26 +372,13 @@
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/plugin/TestPlugIn.h>
+#include "rtl/oustringostreaminserter.hxx"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include <cstddef>
#include <iostream>
-//TODO, copied here from test/oustringostreaminserter.hxx, make DRY again:
-#include "osl/thread.h"
-namespace rtl {
-template< typename charT, typename traits > std::basic_ostream<charT, traits> &
-operator <<(
- std::basic_ostream<charT, traits> & stream, rtl::OUString const & string)
-{
- return stream <<
- rtl::OUStringToOString(string, osl_getThreadTextEncoding()).getStr();
- // best effort; potentially loses data due to conversion failures and
- // embedded null characters
-}
-}
-
namespace com { namespace sun { namespace star { namespace uno {
std::ostream & operator <<(
diff --git a/cppu/qa/test_unotype.cxx b/cppu/qa/test_unotype.cxx
index dbb13d6b1d1f..fa2995b2e2cd 100644
--- a/cppu/qa/test_unotype.cxx
+++ b/cppu/qa/test_unotype.cxx
@@ -55,24 +55,11 @@
#include "com/sun/star/uno/XComponentContext.hpp"
#include "com/sun/star/uno/XInterface.hpp"
#include "cppu/unotype.hxx"
+#include "rtl/oustringostreaminserter.hxx"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "sal/types.h"
-//TODO, copied here from test/oustringostreaminserter.hxx, make DRY again:
-#include "osl/thread.h"
-namespace rtl {
-template< typename charT, typename traits > std::basic_ostream<charT, traits> &
-operator <<(
- std::basic_ostream<charT, traits> & stream, rtl::OUString const & string)
-{
- return stream <<
- rtl::OUStringToOString(string, osl_getThreadTextEncoding()).getStr();
- // best effort; potentially loses data due to conversion failures and
- // embedded null characters
-}
-}
-
namespace com { namespace sun { namespace star { namespace uno {
class Any;
} } } }
diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx
index 672364d9645f..e847c3cf1bea 100644
--- a/desktop/source/deployment/registry/dp_backend.cxx
+++ b/desktop/source/deployment/registry/dp_backend.cxx
@@ -31,8 +31,10 @@
#include "dp_backend.h"
#include "dp_ucb.h"
+#include "rtl/oustringostreaminserter.hxx"
#include "rtl/uri.hxx"
#include "rtl/bootstrap.hxx"
+#include "sal/log.h"
#include "osl/file.hxx"
#include "cppuhelper/exc_hlp.hxx"
#include "comphelper/servicedecl.hxx"
@@ -73,7 +75,7 @@ void PackageRegistryBackend::disposing( lang::EventObject const & event )
::osl::MutexGuard guard( getMutex() );
if ( m_bound.erase( url ) != 1 )
{
- OSL_ASSERT( false );
+ SAL_WARN_S("basic", "erase(" << url << ") != 1");
}
}
@@ -207,8 +209,9 @@ Reference<deployment::XPackage> PackageRegistryBackend::bindPackage(
m_bound.insert( t_string2ref::value_type( url, xNewPackage ) ) );
if (insertion.second)
{ // first insertion
- OSL_ASSERT( Reference<XInterface>(insertion.first->second)
- == xNewPackage );
+ SAL_WARN_IF(
+ Reference<XInterface>(insertion.first->second) != xNewPackage,
+ "desktop", "mismatch");
}
else
{ // found existing entry
@@ -339,7 +342,7 @@ Package::Package( ::rtl::Reference<PackageRegistryBackend> const & myBackend,
if (m_bRemoved)
{
//We use the last segment of the URL
- OSL_ASSERT(m_name.getLength() == 0);
+ SAL_WARN_IF(!m_name.isEmpty(), "basic", "non-empty m_name");
OUString name = m_url;
rtl::Bootstrap::expandMacros(name);
sal_Int32 index = name.lastIndexOf('/');
@@ -679,11 +682,8 @@ void Package::processPackage_impl(
}
catch (RuntimeException &e) {
(void) e; // avoid warnings
- OSL_FAIL(
- OSL_FORMAT(
- "unexpected RuntimeException \"%s\"",
- (rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).
- getStr())));
+ SAL_WARN_S(
+ "basic", "unexpected RuntimeException \"" << e.Message << '"');
throw;
}
catch (CommandFailedException &) {
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/diagnostics.h b/jvmfwk/plugins/sunmajor/pluginlib/diagnostics.h
index 6a8ef3232bc4..eb1cd03c8a8d 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/diagnostics.h
+++ b/jvmfwk/plugins/sunmajor/pluginlib/diagnostics.h
@@ -25,98 +25,20 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-#if !defined INCLUDED_JFW_PLUGIN_DIAGNOSTICS_HXX
-#define INCLUDED_JFW_PLUGIN_DIAGNOSTICS_HXX
-#include "osl/diagnose.h"
-#include "rtl/ustring.hxx"
-#include <stdio.h>
-
-#if OSL_DEBUG_LEVEL >= 1
-#define JFW_ENSURE(c, m) _JFW_ENSURE(c, OSL_THIS_FILE, __LINE__, m)
-#else
-#define JFW_ENSURE(c, m) ((void) 0)
-#endif
-
-#if OSL_DEBUG_LEVEL >= 2
-#define JFW_WARNING2(c, m) _JFW_WARNING2(c, OSL_THIS_FILE, __LINE__, m)
-#else
-#define JFW_WARNING2(c, m) ((void) 0)
-#endif
-
-
-#if OSL_DEBUG_LEVEL >= 0
-#define JFW_TRACE0(m) jfw_trace(m)
-#else
-#define JFW_TRACE0(m) ((void) 0)
-#endif
-
-#if OSL_DEBUG_LEVEL >= 1
-#define JFW_TRACE1(m) jfw_trace(m)
-#else
-#define JFW_TRACE1(m) ((void) 0)
-#endif
-
-#if OSL_DEBUG_LEVEL >= 2
-#define JFW_TRACE2(m) jfw_trace(m)
-#else
-#define JFW_TRACE2(m) ((void) 0)
-#endif
-
-
-#define _JFW_ENSURE(c, f, l, m) jfw_ensure(c, f, l, m)
-#define _JFW_WARNING(c, f, l, m) jfw_warning2(c, f, l, m);
-
-
-namespace jfw_plugin
-{
-
-inline void jfw_ensure(bool
- #if OSL_DEBUG_LEVEL > 0 /* prevent warning in pro version */
- condition
- #endif
- , const sal_Char *
- #if OSL_DEBUG_LEVEL > 0 /* prevent warning in pro version */
- pzFile
- #endif
- , sal_Int32
- #if OSL_DEBUG_LEVEL > 0 /* prevent warning in pro version */
- line
- #endif
- , const rtl::OUString& message )
-{
- rtl::OString oMsg = rtl::OUStringToOString(message, osl_getThreadTextEncoding());
- _OSL_ENSURE(condition, pzFile, line, oMsg.getStr());
-}
+#ifndef INCLUDED_JFW_PLUGIN_DIAGNOSTICS_HXX
+#define INCLUDED_JFW_PLUGIN_DIAGNOSTICS_HXX
-inline void jfw_warning2(bool condition, const sal_Char * pzFile, sal_Int32 line,
- sal_Char * pzMessage)
-{
- if (! condition)
- fprintf(
- stderr, "%s\n File: %s\n Line: %ld", pzMessage, pzFile,
- sal::static_int_cast< unsigned long >(line));
-}
+#include "sal/config.h"
-inline void jfw_trace(rtl::OUString message)
-{
- rtl::OString oMsg = rtl::OUStringToOString(message, osl_getThreadTextEncoding());
- fprintf(stderr,"%s", oMsg.getStr());
-}
+#include "rtl/oustringostreaminserter.hxx"
+#include "sal/log.h"
-inline void jfw_trace(const sal_Char * pzMessage)
-{
- if (pzMessage)
- fprintf(stderr,"%s", pzMessage);
-}
+#define JFW_ENSURE(c, m) SAL_WARN_IF_S(!(c), "jfw", m)
-inline void jfw_trace(const rtl::OString& message)
-{
- if (message.getLength() > 0)
- fprintf(stderr,"%s", message.getStr());
-}
+#define JFW_TRACE0(m) SAL_INFO_S("jfw.level1", m)
-}
+#define JFW_TRACE2(m) SAL_INFO_S("jfw.level2", m);
#endif
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
index 00843ec8f03a..1b2dd2335e39 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
@@ -70,7 +70,6 @@ using ::rtl::OString;
using ::rtl::OUStringBuffer;
using ::rtl::OUStringToOString;
-#define CHAR_POINTER(oustr) ::rtl::OUStringToOString(oustr,RTL_TEXTENCODING_UTF8).pData->buffer
#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
#ifdef WNT
#define HKEY_SUN_JRE L"Software\\JavaSoft\\Java Runtime Environment"
@@ -310,14 +309,13 @@ class AsynchReader: public Thread
public:
AsynchReader(oslFileHandle & rHandle);
-#if OSL_DEBUG_LEVEL >= 2
+
/** only call this function after this thread has finished.
That is, call join on this instance and then call getData.
*/
OString getData();
-#endif
};
AsynchReader::AsynchReader(oslFileHandle & rHandle):
@@ -325,13 +323,11 @@ AsynchReader::AsynchReader(oslFileHandle & rHandle):
{
}
-#if OSL_DEBUG_LEVEL >= 2
OString AsynchReader::getData()
{
OSL_ASSERT(isRunning() == sal_False );
return OString(m_arData.get(), m_nDataSize);
}
-#endif
void AsynchReader::run()
{
@@ -469,8 +465,7 @@ bool getJavaProps(const OUString & exePath,
OUString sLine;
if (!decodeOutput(aLine, &sLine))
continue;
- JFW_TRACE2(OString("[Java framework]:\" ")
- + OString( CHAR_POINTER(sLine)) + OString(" \".\n"));
+ JFW_TRACE2("[Java framework]:\" " << sLine << " \".\n");
sLine = sLine.trim();
if (sLine.getLength() == 0)
continue;
@@ -497,8 +492,8 @@ bool getJavaProps(const OUString & exePath,
//process error stream data
stderrReader.join();
- JFW_TRACE2(OString("[Java framework] Java wrote to stderr:\" ")
- + stderrReader.getData() + OString(" \".\n"));
+ JFW_TRACE2("[Java framework] Java wrote to stderr:\" "
+ << stderrReader.getData().getStr() << " \".\n");
TimeValue waitMax= {5 ,0};
procErr = osl_joinProcessWithTimeout(javaProcess, &waitMax);
diff --git a/sal/inc/osl/diagnose.h b/sal/inc/osl/diagnose.h
index aab76b320f2a..8e889ac5a37a 100644
--- a/sal/inc/osl/diagnose.h
+++ b/sal/inc/osl/diagnose.h
@@ -30,10 +30,25 @@
#ifndef _OSL_DIAGNOSE_H_
#define _OSL_DIAGNOSE_H_
+#include "sal/config.h"
+
+#include <sal/log.h>
#include <sal/types.h>
/** provides simple diagnostic support
+ The facilities provided by this header are deprecated. True assertions
+ (that detect broken program logic) should use standard assert (which aborts
+ 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.
+
+ 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
+ warnings, they map to SAL_WARN instead of standard assert. OSL_TRACE maps
+ to SAL_INFO.
+
The functions defined in this header are not intended to be used directly,
but through defined macros. The macros can be divided into three categories:
assertions, traces and other stuff .-) Their usability depends on the value
@@ -122,14 +137,25 @@ pfunc_osl_printDetailedDebugMessage SAL_CALL osl_setDetailedDebugMessageFunc( pf
#define OSL_THIS_FILE __FILE__
-/* the macro OSL_LOG_PREFIX is intended to be an office internal macro for now */
-#define OSL_LOG_PREFIX OSL_THIS_FILE ":" SAL_STRINGIFY( __LINE__ ) "; "
+/* the macro OSL_LOG_PREFIX is intended to be an office internal macro for now
+
+ it is deprecated and superseded by SAL_WHERE
+*/
+#define OSL_LOG_PREFIX SAL_WHERE
#define OSL_DEBUG_ONLY(s) _OSL_DEBUG_ONLY(s)
-#define OSL_TRACE _OSL_TRACE
-#define OSL_ASSERT(c) _OSL_ENSURE(c, OSL_THIS_FILE, __LINE__, 0)
-#define OSL_ENSURE(c, m) _OSL_ENSURE(c, OSL_THIS_FILE, __LINE__, m)
-#define OSL_FAIL(m) _OSL_ENSURE(0, OSL_THIS_FILE, __LINE__, m)
+
+#if OSL_DEBUG_LEVEL > 0
+#define OSL_TRACE(...) SAL_INFO("legacy.osl", __VA_ARGS__)
+#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)
+#else
+#define OSL_TRACE(...) ((void) 0)
+#define OSL_ASSERT(c) ((void) 0)
+#define OSL_ENSURE(c, m) ((void) 0)
+#define OSL_FAIL(m) ((void) 0)
+#endif
#define OSL_VERIFY(c) do { if (!(c)) OSL_ASSERT(0); } while (0)
#define OSL_PRECOND(c, m) OSL_ENSURE(c, m)
@@ -145,27 +171,10 @@ pfunc_osl_printDetailedDebugMessage SAL_CALL osl_setDetailedDebugMessageFunc( pf
#if OSL_DEBUG_LEVEL > 0
#define _OSL_DEBUG_ONLY(f) (f)
-#define _OSL_ENSURE(c, f, l, m) \
- do \
- { \
- if (!(c) && _OSL_GLOBAL osl_assertFailedLine(f, l, m)) \
- _OSL_GLOBAL osl_breakDebug(); \
- } while (0)
#else
#define _OSL_DEBUG_ONLY(f) ((void)0)
-#define _OSL_ENSURE(c, f, l, m) ((void)0)
-
-#endif /* OSL_DEBUG_LEVEL */
-
-#if OSL_DEBUG_LEVEL > 1
-
-#define _OSL_TRACE _OSL_GLOBAL osl_trace
-
-#else
-
-#define _OSL_TRACE 1 ? ((void)0) : _OSL_GLOBAL osl_trace
#endif /* OSL_DEBUG_LEVEL */
@@ -192,30 +201,6 @@ pfunc_osl_printDetailedDebugMessage SAL_CALL osl_setDetailedDebugMessageFunc( pf
#define OSL_THIS_FUNC ""
#endif
-#if defined __cplusplus
-
-#include "rtl/string.hxx"
-
-/** @internal */
-extern "C" struct _rtl_String * SAL_CALL osl_detail_formatString(
- char const * format, ...) SAL_THROW_EXTERN_C();
- // "struct _rtl_String" instead of "rtl_String" for the case where
- // osl/diagnose.h is included in rtl/string.hxx
-
-/** A facility for printf-style messages in OSL_ENSURE, OSL_FAIL, etc.
-
- Use like: OSL_ENSURE(i == 5, OSL_FORMAT("i should be 5 but is %d", i));
-*/
-#define OSL_FORMAT(format, ...) \
- (::rtl::OString( \
- ::osl_detail_formatString(format, __VA_ARGS__), \
- ::SAL_NO_ACQUIRE).getStr())
- // it appears that all relevant compilers (esp. GCC 4.0 and MS VS 2008
- // Express) already support variadic macros in C++; see also
- // <http://wiki.apache.org/stdcxx/C++0xCompilerSupport>
-
-#endif
-
#endif /* _OSL_DIAGNOSE_H_ */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/inc/osl/diagnose.hxx b/sal/inc/osl/diagnose.hxx
index a9aba130d72b..42e4b8dd7f2f 100644
--- a/sal/inc/osl/diagnose.hxx
+++ b/sal/inc/osl/diagnose.hxx
@@ -25,27 +25,22 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-#if ! defined(OSL_DIAGNOSE_HXX_INCLUDED)
+#ifndef OSL_DIAGNOSE_HXX_INCLUDED
#define OSL_DIAGNOSE_HXX_INCLUDED
-#if ! defined(_OSL_DIAGNOSE_H_)
+#include "sal/config.h"
+
+#include <functional>
+#include <typeinfo>
+
+#include "boost/unordered_set.hpp"
#include "osl/diagnose.h"
-#endif
-#if ! defined(_OSL_INTERLOCK_H_)
#include "osl/interlck.h"
-#endif
-#if ! defined(_OSL_MUTEX_HXX_)
#include "osl/mutex.hxx"
-#endif
-#if ! defined(INCLUDED_RTL_ALLOCATOR_HXX)
#include "rtl/allocator.hxx"
-#endif
-#if ! defined(_RTL_INSTANCE_HXX_)
#include "rtl/instance.hxx"
-#endif
-#include <boost/unordered_set.hpp>
-#include <functional>
-#include <typeinfo>
+#include "sal/log.h"
+#include "sal/types.h"
namespace osl {
/// @internal
@@ -126,7 +121,7 @@ public:
VoidPointerSet::const_iterator iPos(m_data.m_addresses.begin());
VoidPointerSet::const_iterator const iEnd(m_data.m_addresses.end());
for ( ; iPos != iEnd; ++iPos ) {
- OSL_ASSERT( *iPos != 0 );
+ SAL_WARN_IF( *iPos == 0, "sal.debug", "null pointer" );
}
}
return bRet;
@@ -179,7 +174,7 @@ public:
static bool checkObjectCount( ::std::size_t = 0 ) { return true; }
#else // OSL_DEBUG_LEVEL > 0
/** @return whether the expected number of objects is alive,
- else this function OSL_ASSERTs
+ else this function SAL_WARNs
*/
static bool checkObjectCount( ::std::size_t nExpected = 0 ) {
return StaticObjectRegistry::get().checkObjectCount(nExpected);
diff --git a/sal/inc/osl/thread.hxx b/sal/inc/osl/thread.hxx
index 2bcc82fd07eb..2916ff7443d6 100644
--- a/sal/inc/osl/thread.hxx
+++ b/sal/inc/osl/thread.hxx
@@ -29,7 +29,9 @@
#ifndef _THREAD_HXX_
#define _THREAD_HXX_
-#ifdef __cplusplus
+#include "sal/config.h"
+
+#include <cassert>
#include <osl/time.h>
@@ -71,7 +73,7 @@ public:
sal_Bool SAL_CALL create()
{
- OSL_ASSERT(m_hThread == 0); // only one running thread per instance
+ assert(m_hThread == 0); // only one running thread per instance
if (m_hThread)
return sal_False;
@@ -84,7 +86,7 @@ public:
sal_Bool SAL_CALL createSuspended()
{
- OSL_ASSERT(m_hThread == 0); // only one running thread per instance
+ assert(m_hThread == 0); // only one running thread per instance
if( m_hThread)
return sal_False;
m_hThread= osl_createSuspendedThread( threadFunc,
@@ -233,7 +235,7 @@ private:
};
} // end namespace osl
-#endif
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotest/inc/unotest/oustringostreaminserter.hxx b/sal/inc/rtl/oustringostreaminserter.hxx
index 143c3a5c262b..579ffa0cd045 100644
--- a/unotest/inc/unotest/oustringostreaminserter.hxx
+++ b/sal/inc/rtl/oustringostreaminserter.hxx
@@ -24,17 +24,23 @@
* for a copy of the LGPLv3 License.
************************************************************************/
-#ifndef INCLUDED_TEST_OUSTRINGOSTREAMINSERTER_HXX
-#define INCLUDED_TEST_OUSTRINGOSTREAMINSERTER_HXX
+#ifndef INCLUDED_RTL_OUSTRINGOSTREAMINSERTER_HXX
+#define INCLUDED_RTL_OUSTRINGOSTREAMINSERTER_HXX
#include "sal/config.h"
#include <ostream>
-#include "osl/thread.h"
+#include "rtl/textenc.h"
#include "rtl/ustring.hxx"
-// Include this header to support rtl::OUString in CPPUNIT_ASSERT macros.
+/** Include this header to support rtl::OUString in std::ostream (and thus in
+ CPPUNIT_ASSERT macros, for example).
+
+ The rtl::OUString is converted to UTF-8.
+
+ @since LibreOffice 3.5.
+*/
namespace rtl {
@@ -43,9 +49,9 @@ operator <<(
std::basic_ostream<charT, traits> & stream, rtl::OUString const & string)
{
return stream <<
- rtl::OUStringToOString(string, osl_getThreadTextEncoding()).getStr();
- // best effort; potentially loses data due to conversion failures and
- // embedded null characters
+ rtl::OUStringToOString(string, RTL_TEXTENCODING_UTF8).getStr();
+ // best effort; potentially loses data due to conversion failures
+ // (stray surrogate halves) and embedded null characters
}
}
diff --git a/sal/inc/rtl/strbuf.hxx b/sal/inc/rtl/strbuf.hxx
index 962d3dfda8a0..5f0b9b3fecc0 100644
--- a/sal/inc/rtl/strbuf.hxx
+++ b/sal/inc/rtl/strbuf.hxx
@@ -29,7 +29,10 @@
#ifndef _RTL_STRBUF_HXX_
#define _RTL_STRBUF_HXX_
-#include "osl/diagnose.h"
+#include "sal/config.h"
+
+#include <cassert>
+
#include <rtl/strbuf.h>
#include <rtl/string.hxx>
@@ -253,7 +256,7 @@ public:
*/
void setLength(sal_Int32 newLength)
{
- OSL_ASSERT(newLength >= 0);
+ assert(newLength >= 0);
// Avoid modifications if pData points to const empty string:
if( newLength != pData->length )
{
@@ -280,7 +283,7 @@ public:
*/
sal_Char charAt( sal_Int32 index )
{
- OSL_ASSERT(index >= 0 && index < pData->length);
+ assert(index >= 0 && index < pData->length);
return pData->buffer[ index ];
}
@@ -321,7 +324,7 @@ public:
*/
OStringBuffer & setCharAt(sal_Int32 index, sal_Char ch)
{
- OSL_ASSERT(index >= 0 && index < pData->length);
+ assert(index >= 0 && index < pData->length);
pData->buffer[ index ] = ch;
return *this;
}
diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx
index ee4101188013..007129a7dc0f 100644
--- a/sal/inc/rtl/string.hxx
+++ b/sal/inc/rtl/string.hxx
@@ -29,12 +29,15 @@
#ifndef _RTL_STRING_HXX_
#define _RTL_STRING_HXX_
-#ifdef __cplusplus
+#include "sal/config.h"
+
+#include <cassert>
#include <osl/diagnose.h>
#include <rtl/memory.h>
#include <rtl/textenc.h>
#include <rtl/string.h>
+#include "sal/log.h"
#if !defined EXCEPTIONS_OFF
#include <new>
@@ -183,13 +186,13 @@ public:
{
pData = 0;
rtl_uString2String( &pData, value, length, encoding, convertFlags );
+ if (pData == 0) {
#if defined EXCEPTIONS_OFF
- OSL_ASSERT(pData != NULL);
+ SAL_WARN("sal", "std::bad_alloc but EXCEPTIONS_OFF");
#else
- if (pData == 0) {
throw std::bad_alloc();
- }
#endif
+ }
}
/**
@@ -655,7 +658,7 @@ public:
*/
OString copy( sal_Int32 beginIndex ) const SAL_THROW(())
{
- OSL_ASSERT(beginIndex >= 0 && beginIndex <= getLength());
+ assert(beginIndex >= 0 && beginIndex <= getLength());
if ( beginIndex == 0 )
return *this;
else
@@ -679,8 +682,8 @@ public:
*/
OString copy( sal_Int32 beginIndex, sal_Int32 count ) const SAL_THROW(())
{
- OSL_ASSERT(beginIndex >= 0 && beginIndex <= getLength()
- && count >= 0 && count <= getLength() - beginIndex);
+ assert(beginIndex >= 0 && beginIndex <= getLength()
+ && count >= 0 && count <= getLength() - beginIndex);
if ( (beginIndex == 0) && (count == getLength()) )
return *this;
else
@@ -1034,8 +1037,6 @@ struct OStringHash
} /* Namespace */
-#endif /* __cplusplus */
-
#endif /* _RTL_STRING_HXX_ */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx
index 60bb750a1dc7..2456316274d2 100644
--- a/sal/inc/rtl/ustrbuf.hxx
+++ b/sal/inc/rtl/ustrbuf.hxx
@@ -29,12 +29,14 @@
#ifndef _RTL_USTRBUF_HXX_
#define _RTL_USTRBUF_HXX_
+#include "sal/config.h"
+
+#include <cassert>
+
#include <osl/diagnose.h>
#include <rtl/ustrbuf.h>
#include <rtl/ustring.hxx>
-#ifdef __cplusplus
-
namespace rtl
{
@@ -233,7 +235,7 @@ public:
*/
void setLength(sal_Int32 newLength)
{
- OSL_ASSERT(newLength >= 0);
+ assert(newLength >= 0);
// Avoid modifications if pData points to const empty string:
if( newLength != pData->length )
{
@@ -260,7 +262,7 @@ public:
*/
sal_Unicode charAt( sal_Int32 index ) const
{
- OSL_ASSERT(index >= 0 && index < pData->length);
+ assert(index >= 0 && index < pData->length);
return pData->buffer[ index ];
}
@@ -301,7 +303,7 @@ public:
*/
OUStringBuffer & setCharAt(sal_Int32 index, sal_Unicode ch)
{
- OSL_ASSERT(index >= 0 && index < pData->length);
+ assert(index >= 0 && index < pData->length);
pData->buffer[ index ] = ch;
return *this;
}
@@ -434,7 +436,7 @@ public:
*/
OUStringBuffer & append(char c)
{
- OSL_ASSERT(static_cast< unsigned char >(c) <= 0x7F);
+ assert(static_cast< unsigned char >(c) <= 0x7F);
return append(sal_Unicode(c));
}
@@ -819,7 +821,6 @@ private:
}
-#endif /* __cplusplus */
#endif /* _RTL_USTRBUF_HXX_ */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx
index edf7c9747962..ef13dd1da387 100644
--- a/sal/inc/rtl/ustring.hxx
+++ b/sal/inc/rtl/ustring.hxx
@@ -29,12 +29,15 @@
#ifndef _RTL_USTRING_HXX_
#define _RTL_USTRING_HXX_
-#ifdef __cplusplus
+#include "sal/config.h"
+
+#include <cassert>
#include "osl/diagnose.h"
#include <rtl/ustring.h>
#include <rtl/string.hxx>
#include <rtl/memory.h>
+#include "sal/log.h"
#if defined EXCEPTIONS_OFF
#include <stdlib.h>
@@ -184,13 +187,13 @@ public:
{
pData = 0;
rtl_string2UString( &pData, value, length, encoding, convertFlags );
+ if (pData == 0) {
#if defined EXCEPTIONS_OFF
- OSL_ASSERT(pData != NULL);
+ SAL_WARN("sal", "std::bad_alloc but EXCEPTIONS_OFF");
#else
- if (pData == 0) {
throw std::bad_alloc();
- }
#endif
+ }
}
/** Create a new string from an array of Unicode code points.
@@ -967,7 +970,7 @@ public:
*/
OUString copy( sal_Int32 beginIndex ) const SAL_THROW(())
{
- OSL_ASSERT(beginIndex >= 0 && beginIndex <= getLength());
+ assert(beginIndex >= 0 && beginIndex <= getLength());
if ( beginIndex == 0 )
return *this;
else
@@ -991,7 +994,7 @@ public:
*/
OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const SAL_THROW(())
{
- OSL_ASSERT(beginIndex >= 0 && beginIndex <= getLength() && count >= 0);
+ assert(beginIndex >= 0 && beginIndex <= getLength() && count >= 0);
if ( (beginIndex == 0) && (count == getLength()) )
return *this;
else
@@ -1243,13 +1246,13 @@ public:
{
rtl_uString * pNew = 0;
rtl_uString_intern( &pNew, pData );
+ if (pNew == 0) {
#if defined EXCEPTIONS_OFF
- OSL_ASSERT(pNew != NULL);
+ SAL_WARN("sal", "std::bad_alloc but EXCEPTIONS_OFF");
#else
- if (pNew == 0) {
throw std::bad_alloc();
- }
#endif
+ }
return OUString( pNew, (DO_NOT_ACQUIRE *)0 );
}
@@ -1286,13 +1289,13 @@ public:
rtl_uString * pNew = 0;
rtl_uString_internConvert( &pNew, value, length, encoding,
convertFlags, pInfo );
+ if (pNew == 0) {
#if defined EXCEPTIONS_OFF
- OSL_ASSERT(pNew != NULL);
+ SAL_WARN("sal", "std::bad_alloc but EXCEPTIONS_OFF");
#else
- if (pNew == 0) {
throw std::bad_alloc();
- }
#endif
+ }
return OUString( pNew, (DO_NOT_ACQUIRE *)0 );
}
@@ -1576,8 +1579,6 @@ inline OString OUStringToOString( const OUString & rUnicode,
} /* Namespace */
-#endif /* __cplusplus */
-
#endif /* _RTL_USTRING_HXX */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/inc/sal/log.h b/sal/inc/sal/log.h
new file mode 100644
index 000000000000..9e15560aa2c1
--- /dev/null
+++ b/sal/inc/sal/log.h
@@ -0,0 +1,305 @@
+/* -*- 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_LOG_H
+#define INCLUDED_SAL_LOG_H
+
+#include "sal/config.h"
+
+#if defined __cplusplus
+#include <sstream>
+#include <string>
+#endif
+
+#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
+};
+
+/** @internal */
+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
+
+namespace sal { namespace detail {
+
+/// @internal
+inline void SAL_CALL log(
+ sal_detail_LogLevel level, char const * area, char const * where,
+ std::ostringstream const & stream)
+{
+ // An alternative would be to have sal_detail_log take a std::ostringstream
+ // pointer (via a C void pointer); the advantage would be smaller client
+ // code (the ".str().c_str()" part would move into the implementation of
+ // sal_detail_log) and potential for proper support of embedded null
+ // characters within the message, but the disadvantage would be dependence
+ // on the C++ ABI; as a compromise, the ".str().c_str()" part has been moved
+ // to this inline function so that it is potentially only emitted once per
+ // dynamic library:
+ sal_detail_log(level, area, where, stream.str().c_str());
+}
+
+} }
+
+/// @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); \
+ } \
+ } while (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
+ automatically), but also when creating exception messages.
+
+ @since LibreOffice 3.5
+*/
+#define SAL_WHERE __FILE__ ":" SAL_STRINGIFY(__LINE__) ": "
+
+#if defined __cplusplus
+
+/** 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
+ message, as in:
+
+ SAL_INFO_S(
+ "foo", "object: " << (hasName ? obj->name : SAL_STREAM(obj)));
+
+ @since LibreOffice 3.5
+*/
+#define SAL_STREAM(stream) \
+ (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.
+ 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.
+
+ SAL_INFO_S("foo", "string " << s << " of length " << n)
+
+ would be an example of such a call; if the given s is of type rtl::OUString,
+
+ #include "rtl/oustringostreaminserter.hxx"
+
+ would make sure that an appropriate operator << is available.
+
+ In either case, the composed message should be in UTF-8 and it should
+ contain no vertical formatting characters and no null characters
+
+ For the _IF variants, log output is only generated if the given condition is
+ true (in addition to the other conditions that have to be met).
+
+ For all these macros, the given area argument must be non-null and must
+ match the regular expression
+
+ <area> ::= <segment>("."<segment>)*
+
+ with
+
+ <segment> ::= [0-9a-z]+
+
+ Whether these macros generate any log output is controlled in a two-stage
+ process.
+
+ First, at compile time the macros SAL_LOG_INFO and SAL_LOG_WARN,
+ respectively, control whether the INFO and WARN macros, respectively,
+ expand to actual code (in case the macro is defined, to any value) or to
+ no-ops (in case the macro is not defined).
+
+ Second, at runtime the environment variable SAL_LOG further limits which
+ macro calls actually generate log output. The environment variable SAL_LOG
+ must either be unset or must match the regular expression
+
+ <env> ::= <switch>*
+
+ with
+
+ <switch> ::= <sense><level>("."<area>)?
+ <sense> ::= "+"|"-"
+ <level> ::= "INFO"|"WARN"
+
+ 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).
+
+ 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
+ the given level and for which the area is a prefix (including both empty and
+ full prefixes) of the given area are considered. Log output is generated if
+ and only if among the longest such switches (if any), there is at least one
+ that has a sense of "+". (That is, if both +INFO.foo and -INFO.foo are
+ present, +INFO.foo wins.)
+
+ 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
+ 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.
+
+ @since LibreOffice 3.5
+*/
+
+#if defined SAL_LOG_INFO
+
+#define SAL_INFO(area, ...) \
+ SAL_DETAIL_LOG_FORMAT( \
+ sal_True, SAL_DETAIL_LOG_LEVEL_INFO, area, SAL_WHERE, __VA_ARGS__)
+#define SAL_INFO_IF(condition, area, ...) \
+ SAL_DETAIL_LOG_FORMAT( \
+ condition, SAL_DETAIL_LOG_LEVEL_INFO, area, SAL_WHERE, __VA_ARGS__)
+
+#if defined __cplusplus
+#define SAL_INFO_S(area, stream) \
+ SAL_DETAIL_LOG_STREAM( \
+ true, ::SAL_DETAIL_LOG_LEVEL_INFO, area, SAL_WHERE, stream)
+#define SAL_INFO_IF_S(condition, area, stream) \
+ SAL_DETAIL_LOG_STREAM( \
+ condition, ::SAL_DETAIL_LOG_LEVEL_INFO, area, SAL_WHERE, stream)
+#endif
+
+#else
+
+#define SAL_INFO(area, format, ...) ((void) 0)
+#define SAL_INFO_IF(condition, area, format, ...) ((void) 0)
+
+#if defined __cplusplus
+#define SAL_INFO_S(area, stream) ((void) 0)
+#define SAL_INFO_IF_S(condition, area, stream) ((void) 0)
+#endif
+
+#endif
+
+#if defined SAL_LOG_WARN
+
+#define SAL_WARN(area, ...) \
+ SAL_DETAIL_LOG_FORMAT( \
+ sal_True, SAL_DETAIL_LOG_LEVEL_WARN, area, SAL_WHERE, __VA_ARGS__)
+#define SAL_WARN_IF(condition, area, ...) \
+ SAL_DETAIL_LOG_FORMAT( \
+ condition, SAL_DETAIL_LOG_LEVEL_WARN, area, SAL_WHERE, __VA_ARGS__)
+
+#if defined __cplusplus
+#define SAL_WARN_S(area, stream) \
+ SAL_DETAIL_LOG_STREAM( \
+ true, ::SAL_DETAIL_LOG_LEVEL_WARN, area, SAL_WHERE, stream)
+#define SAL_WARN_IF_S(condition, area, stream) \
+ SAL_DETAIL_LOG_STREAM( \
+ condition, ::SAL_DETAIL_LOG_LEVEL_WARN, area, SAL_WHERE, stream)
+#endif
+
+#else
+
+#define SAL_WARN(area, format, ...) ((void) 0)
+#define SAL_WARN_IF(condition, area, format, ...) ((void) 0)
+
+#if defined __cplusplus
+#define SAL_WARN_S(area, stream) ((void) 0)
+#define SAL_WARN_IF_S(condition, area, stream) ((void) 0)
+#endif
+
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
new file mode 100644
index 000000000000..be45cf629b81
--- /dev/null
+++ b/sal/osl/all/log.cxx
@@ -0,0 +1,199 @@
+/* -*- 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.
+ */
+
+#include "precompiled_sal.hxx"
+#include "sal/config.h"
+
+#include <cassert>
+#include <cstdarg>
+#include <cstddef>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <sstream>
+
+#include <stdio.h> // vsnprintf
+
+#include "osl/thread.hxx"
+#include "rtl/string.h"
+#include "sal/log.h"
+#include "sal/types.h"
+
+#include "logformat.hxx"
+
+#if defined WNT
+#include <process.h>
+#define OSL_DETAIL_GETPID _getpid()
+#else
+#include <unistd.h>
+#define OSL_DETAIL_GETPID getpid()
+#endif
+
+// Avoid the use of other sal code in this file as much as possible, so that
+// this code can be called from other sal code without causing endless
+// recursion.
+
+namespace {
+
+bool equalStrings(
+ char const * string1, std::size_t length1, char const * string2,
+ std::size_t length2)
+{
+ return length1 == length2 && std::memcmp(string1, string2, length1) == 0;
+}
+
+char const * toString(sal_detail_LogLevel level) {
+ switch (level) {
+ default:
+ assert(false); // this cannot happen
+ // fall through
+ case SAL_DETAIL_LOG_LEVEL_INFO:
+ return "info";
+ case SAL_DETAIL_LOG_LEVEL_WARN:
+ return "warn";
+ }
+}
+
+bool report(sal_detail_LogLevel level, char const * area) {
+ assert(area != 0);
+ char const * env = std::getenv("SAL_LOG");
+ if (env == 0) {
+ 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)
+ for (char const * p = env;;) {
+ Sense sense;
+ switch (*p++) {
+ case '\0':
+ return senseLen[POSITIVE] >= senseLen[NEGATIVE];
+ // if a specific item is both postiive 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;
+ } 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)
+{
+ std::ostringstream s;
+ s << toString(level) << ':' << area << ':' << OSL_DETAIL_GETPID << ':'
+ << osl::Thread::getCurrentIdentifier() << ':' << where << message
+ << '\n';
+ std::fputs(s.str().c_str(), stderr);
+}
+
+}
+
+void sal_detail_log(
+ sal_detail_LogLevel level, char const * area, char const * where,
+ char const * message)
+{
+ if (report(level, area)) {
+ log(level, area, where, message);
+ }
+}
+
+void sal_detail_logFormat(
+ sal_detail_LogLevel level, char const * area, char const * where,
+ char const * format, ...)
+{
+ if (report(level, area)) {
+ std::va_list args;
+ va_start(args, format);
+ osl::detail::logFormat(level, area, where, format, args);
+ va_end(args);
+ }
+}
+
+void osl::detail::logFormat(
+ sal_detail_LogLevel level, char const * area, char const * where,
+ char const * format, std::va_list arguments)
+{
+ char buf[1024];
+ int const len = sizeof buf - RTL_CONSTASCII_LENGTH("...");
+ int n = vsnprintf(buf, len, format, arguments);
+ if (n < 0) {
+ std::strcpy(buf, "???");
+ } else if (n >= len) {
+ std::strcpy(buf + len - 1, "...");
+ }
+ log(level, area, where, buf);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/all/logformat.hxx b/sal/osl/all/logformat.hxx
new file mode 100644
index 000000000000..f4589a7b9f94
--- /dev/null
+++ b/sal/osl/all/logformat.hxx
@@ -0,0 +1,49 @@
+/* -*- 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_OSL_ALL_LOGFORMAT_HXX
+#define INCLUDED_SAL_OSL_ALL_LOGFORMAT_HXX
+
+#include "sal/config.h"
+
+#include <cstdarg>
+
+#include "sal/log.h"
+
+namespace osl { namespace detail {
+
+void logFormat(
+ sal_detail_LogLevel level, char const * area, char const * where,
+ char const * format, std::va_list arguments);
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/all/makefile.mk b/sal/osl/all/makefile.mk
index d9db5b7bb749..e76388af7ff4 100644
--- a/sal/osl/all/makefile.mk
+++ b/sal/osl/all/makefile.mk
@@ -50,18 +50,18 @@ CXXFLAGS+= $(LFS_CFLAGS)
SLOFILES= \
$(SLO)$/utility.obj\
$(SLO)$/filepath.obj\
- $(SLO)$/formatstring.obj\
$(SLO)$/debugbase.obj\
$(SLO)$/loadmodulerelative.obj \
- $(SLO)/printtrace.obj
+ $(SLO)/log.obj\
+ $(SLO)/trace.obj
OBJFILES= \
$(OBJ)$/utility.obj\
$(OBJ)$/filepath.obj\
- $(OBJ)$/formatstring.obj\
$(OBJ)$/debugbase.obj\
$(OBJ)$/loadmodulerelative.obj \
- $(OBJ)/printtrace.obj
+ $(OBJ)/log.obj\
+ $(OBJ)/trace.obj
# --- Targets ------------------------------------------------------
diff --git a/sal/osl/all/printtrace.cxx b/sal/osl/all/printtrace.cxx
deleted file mode 100644
index 0ecd6f47c466..000000000000
--- a/sal/osl/all/printtrace.cxx
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
-*
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* Copyright 2000, 2010 Oracle and/or its affiliates.
-*
-* OpenOffice.org - a multi-platform office productivity suite
-*
-* This file is part of OpenOffice.org.
-*
-* OpenOffice.org is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Lesser General Public License version 3
-* only, as published by the Free Software Foundation.
-*
-* OpenOffice.org is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU Lesser General Public License version 3 for more details
-* (a copy is included in the LICENSE file that accompanied this code).
-*
-* You should have received a copy of the GNU Lesser General Public License
-* version 3 along with OpenOffice.org. If not, see
-* <http://www.openoffice.org/license.html>
-* for a copy of the LGPLv3 License.
-*
-************************************************************************/
-
-#include "precompiled_sal.hxx"
-
-#include "sal/config.h"
-
-#include <cstdarg>
-#include <cstdio>
-#include <cstring>
-
-#include <stdio.h> // snprintf, vsnprintf
-
-#include "osl/diagnose.h"
-#include "osl/thread.hxx"
-#include "rtl/string.h"
-#include "sal/types.h"
-
-#include "printtrace.h"
-
-void printTrace(unsigned long pid, char const * format, std::va_list arguments)
-{
- char buf[1024];
- int n1 = snprintf(
- buf, sizeof buf, "Trace %lu/%" SAL_PRIuUINT32 ": \"", pid,
- osl::Thread::getCurrentIdentifier());
- OSL_ASSERT(
- n1 >= 0 &&
- (static_cast< unsigned int >(n1) <
- sizeof buf - RTL_CONSTASCII_LENGTH("\"...\n")));
- int n2 = sizeof buf - n1 - RTL_CONSTASCII_LENGTH("\"...\n");
- int n3 = vsnprintf(buf + n1, n2, format, arguments);
- if (n3 < 0) {
- std::strcpy(buf + n1, "\"???\n");
- } else if (n3 < n2) {
- std::strcpy(buf + n1 + n3, "\"\n");
- } else {
- std::strcpy(buf + n1 + n2 - 1, "\"...\n");
- }
- std::fputs(buf, stderr);
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/all/formatstring.cxx b/sal/osl/all/trace.cxx
index 9fefa2f52cfe..835704779452 100644
--- a/sal/osl/all/formatstring.cxx
+++ b/sal/osl/all/trace.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
*
@@ -12,8 +13,8 @@
* License.
*
* Major Contributor(s):
- * [ Copyright (C) 2011 Stephan Bergmann, Red Hat Inc. <sbergman@redhat.com>
- * (initial developer) ]
+ * [ Copyright (C) 2011 Stephan Bergmann, Red Hat <sbergman@redhat.com> (initial
+ * developer) ]
*
* All Rights Reserved.
*
@@ -30,32 +31,18 @@
#include "sal/config.h"
#include <cstdarg>
-#include <cstring>
-#include <stdio.h> // vsnprintf not in C++03 <cstdio>, only C99 <stdio.h>
#include "osl/diagnose.h"
-#include "rtl/string.h"
-#include "rtl/string.hxx"
+#include "sal/log.h"
-rtl_String * osl_detail_formatString(char const * format, ...)
- SAL_THROW_EXTERN_C()
-{
- // Avoid the use of other sal code as much as possible, so that this code
- // can be called from other sal code without causing endless recursion:
- char buf[1024];
- int n1 = sizeof buf - RTL_CONSTASCII_LENGTH("...");
+#include "logformat.hxx"
+
+void osl_trace(char const * pszFormat, ...) {
std::va_list args;
- va_start(args, format);
- int n2 = vsnprintf(buf, n1, format, args);
+ va_start(args, pszFormat);
+ osl::detail::logFormat(
+ SAL_DETAIL_LOG_LEVEL_INFO, "legacy.osl", SAL_WHERE, pszFormat, args);
va_end(args);
- if (n2 < 0) {
- std::strcpy(buf, "???");
- n2 = RTL_CONSTASCII_LENGTH("???");
- } else if (n2 >= n1) {
- std::strcpy(buf + n1 - 1, "...");
- n2 = sizeof buf - 1;
- }
- rtl::OString s(buf, n2);
- rtl_string_acquire(s.pData);
- return s.pData;
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/inc/printtrace.h b/sal/osl/inc/printtrace.h
deleted file mode 100644
index a2bca913a1f6..000000000000
--- a/sal/osl/inc/printtrace.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
-*
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* Copyright 2000, 2010 Oracle and/or its affiliates.
-*
-* OpenOffice.org - a multi-platform office productivity suite
-*
-* This file is part of OpenOffice.org.
-*
-* OpenOffice.org is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Lesser General Public License version 3
-* only, as published by the Free Software Foundation.
-*
-* OpenOffice.org is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU Lesser General Public License version 3 for more details
-* (a copy is included in the LICENSE file that accompanied this code).
-*
-* You should have received a copy of the GNU Lesser General Public License
-* version 3 along with OpenOffice.org. If not, see
-* <http://www.openoffice.org/license.html>
-* for a copy of the LGPLv3 License.
-*
-************************************************************************/
-
-#ifndef INCLUDED_SAL_OSL_INC_PRINTTRACE_H
-#define INCLUDED_SAL_OSL_INC_PRINTTRACE_H
-
-#include "sal/config.h"
-
-#include <stdarg.h>
-
-#if defined __cplusplus
-extern "C" {
-#endif
-
-/* called internally by osl_trace */
-void printTrace(unsigned long pid, char const * format, va_list arguments);
-
-#if defined __cplusplus
-}
-#endif
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/unx/conditn.c b/sal/osl/unx/conditn.c
index ac6c92630d0f..d7ab7131938c 100644
--- a/sal/osl/unx/conditn.c
+++ b/sal/osl/unx/conditn.c
@@ -26,12 +26,15 @@
*
************************************************************************/
+#include "sal/config.h"
+
+#include <assert.h>
#include "system.h"
+#include <sal/log.h>
#include <sal/types.h>
#include <osl/conditn.h>
-#include <osl/diagnose.h>
#include <osl/time.h>
@@ -53,10 +56,9 @@ oslCondition SAL_CALL osl_createCondition()
pCond = (oslConditionImpl*) malloc(sizeof(oslConditionImpl));
- OSL_ASSERT(pCond);
-
if ( pCond == 0 )
{
+ SAL_WARN("sal", "std::bad_alloc in C");
return 0;
}
@@ -66,8 +68,9 @@ oslCondition SAL_CALL osl_createCondition()
nRet = pthread_cond_init(&pCond->m_Condition, PTHREAD_CONDATTR_DEFAULT);
if ( nRet != 0 )
{
- OSL_TRACE("osl_createCondition : condition init failed. Errno: %d; '%s'\n",
- nRet, strerror(nRet));
+ SAL_WARN(
+ "sal", "pthread_cond_init failed, errno %d, \"%s\"", nRet,
+ strerror(nRet));
free(pCond);
return 0;
@@ -76,15 +79,14 @@ oslCondition SAL_CALL osl_createCondition()
nRet = pthread_mutex_init(&pCond->m_Lock, PTHREAD_MUTEXATTR_DEFAULT);
if ( nRet != 0 )
{
- OSL_TRACE("osl_createCondition : mutex init failed. Errno: %d; %s\n",
- nRet, strerror(nRet));
+ SAL_WARN(
+ "sal", "pthread_mutex_init failed, errno %d, \"%s\"", nRet,
+ strerror(nRet));
nRet = pthread_cond_destroy(&pCond->m_Condition);
- if ( nRet != 0 )
- {
- OSL_TRACE("osl_createCondition : destroy condition failed. Errno: %d; '%s'\n",
- nRet, strerror(nRet));
- }
+ SAL_WARN_IF(
+ nRet != 0, "sal", "pthread_cond_destroy failed, errno %d, \"%s\"",
+ nRet, strerror(nRet));
free(pCond);
pCond = 0;
@@ -106,17 +108,13 @@ void SAL_CALL osl_destroyCondition(oslCondition Condition)
pCond = (oslConditionImpl*)Condition;
nRet = pthread_cond_destroy(&pCond->m_Condition);
- if ( nRet != 0 )
- {
- OSL_TRACE("osl_destroyCondition : destroy condition failed. Errno: %d; '%s'\n",
- nRet, strerror(nRet));
- }
+ SAL_WARN_IF(
+ nRet != 0, "sal", "pthread_cond_destroy failed, errno %d, \"%s\"",
+ nRet, strerror(nRet));
nRet = pthread_mutex_destroy(&pCond->m_Lock);
- if ( nRet != 0 )
- {
- OSL_TRACE("osl_destroyCondition : destroy mutex failed. Errno: %d; '%s'\n",
- nRet, strerror(nRet));
- }
+ SAL_WARN_IF(
+ nRet != 0, "sal", "pthread_mutex_destroy failed, errno %d, \"%s\"",
+ nRet, strerror(nRet));
free(Condition);
}
@@ -132,7 +130,7 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition)
oslConditionImpl* pCond;
int nRet=0;
- OSL_ASSERT(Condition);
+ assert(Condition);
pCond = (oslConditionImpl*)Condition;
if ( pCond == 0 )
@@ -143,8 +141,9 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition)
nRet = pthread_mutex_lock(&pCond->m_Lock);
if ( nRet != 0 )
{
- OSL_TRACE("osl_setCondition : mutex lock failed. Errno: %d; %s\n",
- nRet, strerror(nRet));
+ SAL_WARN(
+ "sal", "pthread_mutex_lock failed, errno %d, \"%s\"", nRet,
+ strerror(nRet));
return sal_False;
}
@@ -152,16 +151,18 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition)
nRet = pthread_cond_broadcast(&pCond->m_Condition);
if ( nRet != 0 )
{
- OSL_TRACE("osl_setCondition : condition broadcast failed. Errno: %d; %s\n",
- nRet, strerror(nRet));
+ SAL_WARN(
+ "sal", "pthread_cond_broadcast failed, errno %d, \"%s\"", nRet,
+ strerror(nRet));
return sal_False;
}
nRet = pthread_mutex_unlock(&pCond->m_Lock);
if ( nRet != 0 )
{
- OSL_TRACE("osl_setCondition : mutex unlock failed. Errno: %d; %s\n",
- nRet, strerror(nRet));
+ SAL_WARN(
+ "sal", "pthread_mutex_unlock failed, errno %d, \"%s\"", nRet,
+ strerror(nRet));
return sal_False;
}
@@ -177,7 +178,7 @@ sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition)
oslConditionImpl* pCond;
int nRet=0;
- OSL_ASSERT(Condition);
+ assert(Condition);
pCond = (oslConditionImpl*)Condition;
@@ -189,8 +190,9 @@ sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition)
nRet = pthread_mutex_lock(&pCond->m_Lock);
if ( nRet != 0 )
{
- OSL_TRACE("osl_resetCondition : mutex lock failed. Errno: %d; %s\n",
- nRet, strerror(nRet));
+ SAL_WARN(
+ "sal", "pthread_mutex_lock failed, errno %d, \"%s\"", nRet,
+ strerror(nRet));
return sal_False;
}
@@ -199,8 +201,9 @@ sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition)
nRet = pthread_mutex_unlock(&pCond->m_Lock);
if ( nRet != 0 )
{
- OSL_TRACE("osl_resetCondition : mutex unlock failed. Errno: %d; %s\n",
- nRet, strerror(nRet));
+ SAL_WARN(
+ "sal", "pthread_mutex_unlock failed, errno %d, \"%s\"", nRet,
+ strerror(nRet));
return sal_False;
}
@@ -216,7 +219,7 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
int nRet=0;
oslConditionResult Result = osl_cond_result_ok;
- OSL_ASSERT(Condition);
+ assert(Condition);
pCond = (oslConditionImpl*)Condition;
if ( pCond == 0 )
@@ -227,8 +230,9 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
nRet = pthread_mutex_lock(&pCond->m_Lock);
if ( nRet != 0 )
{
- OSL_TRACE("osl_waitCondition : mutex lock failed. Errno: %d; %s\n",
- nRet, strerror(nRet));
+ SAL_WARN(
+ "sal", "pthread_mutex_lock failed, errno %d, \"%s\"", nRet,
+ strerror(nRet));
return osl_cond_result_error;
}
@@ -255,11 +259,10 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
{
Result = osl_cond_result_timeout;
nRet = pthread_mutex_unlock(&pCond->m_Lock);
- if (nRet != 0)
- {
- OSL_TRACE("osl_waitCondition : mutex unlock failed. Errno: %d; %s\n",
- nRet, strerror(nRet));
- }
+ SAL_WARN_IF(
+ nRet != 0, "sal",
+ "pthread_mutex_unlock failed, errno %d, \"%s\"",
+ nRet, strerror(nRet));
return Result;
}
@@ -267,14 +270,12 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
{
Result = osl_cond_result_error;
nRet = pthread_mutex_unlock(&pCond->m_Lock);
- if ( nRet != 0 )
- {
- OSL_TRACE("osl_waitCondition : mutex unlock failed. Errno: %d; %s\n",
- nRet, strerror(nRet));
- }
+ SAL_WARN_IF(
+ nRet != 0, "sal",
+ "pthread_mutex_unlock failed, errno %d, \"%s\"",
+ nRet, strerror(nRet));
return Result;
}
-/* OSL_TRACE("EINTR\n");*/
}
}
while ( !pCond->m_State );
@@ -287,15 +288,15 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
nRet = pthread_cond_wait(&pCond->m_Condition, &pCond->m_Lock);
if ( nRet != 0 )
{
- OSL_TRACE("osl_waitCondition : condition wait failed. Errno: %d; %s\n",
- nRet, strerror(nRet));
+ SAL_WARN(
+ "sal", "pthread_cond_wait failed, errno %d, \"%s\"", nRet,
+ strerror(nRet));
Result = osl_cond_result_error;
nRet = pthread_mutex_unlock(&pCond->m_Lock);
- if ( nRet != 0 )
- {
- OSL_TRACE("osl_waitCondition : mutex unlock failed. Errno: %d; %s\n",
- nRet, strerror(nRet));
- }
+ SAL_WARN_IF(
+ nRet != 0, "sal",
+ "pthread_mutex_unlock failed, errno %d, \"%s\"", nRet,
+ strerror(nRet));
return Result;
}
@@ -303,11 +304,9 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
}
nRet = pthread_mutex_unlock(&pCond->m_Lock);
- if ( nRet != 0 )
- {
- OSL_TRACE("osl_waitCondition : mutex unlock failed. Errno: %d; %s\n",
- nRet, strerror(nRet));
- }
+ SAL_WARN_IF(
+ nRet != 0, "sal", "pthread_mutex_unlock failed, errno %d, \"%s\"", nRet,
+ strerror(nRet));
return Result;
}
@@ -321,7 +320,7 @@ sal_Bool SAL_CALL osl_checkCondition(oslCondition Condition)
oslConditionImpl* pCond;
int nRet=0;
- OSL_ASSERT(Condition);
+ assert(Condition);
pCond = (oslConditionImpl*)Condition;
if ( pCond == 0 )
@@ -330,20 +329,16 @@ sal_Bool SAL_CALL osl_checkCondition(oslCondition Condition)
}
nRet = pthread_mutex_lock(&pCond->m_Lock);
- if ( nRet != 0 )
- {
- OSL_TRACE("osl_checkCondition : mutex unlock failed. Errno: %d; %s\n",
- nRet, strerror(nRet));
- }
+ SAL_WARN_IF(
+ nRet != 0, "sal", "pthread_mutex_lock failed, errno %d, \"%s\"", nRet,
+ strerror(nRet));
State = pCond->m_State;
nRet = pthread_mutex_unlock(&pCond->m_Lock);
- if ( nRet != 0 )
- {
- OSL_TRACE("osl_checkCondition : mutex unlock failed. Errno: %d; %s\n",
- nRet, strerror(nRet));
- }
+ SAL_WARN_IF(
+ nRet != 0, "sal", "pthread_mutex_unlock failed, errno %d, \"%s\"", nRet,
+ strerror(nRet));
return State;
}
diff --git a/sal/osl/unx/diagnose.c b/sal/osl/unx/diagnose.c
index 7832b16a6d36..5b46a615aa6b 100644
--- a/sal/osl/unx/diagnose.c
+++ b/sal/osl/unx/diagnose.c
@@ -46,7 +46,6 @@
#endif
#endif /* HAVE_DLFCN_H */
-#include "osl/thread.h"
#ifndef INCLUDED_PTHREAD_H
#include <pthread.h>
@@ -58,8 +57,6 @@
#define INCLUDED_STDDEF_H
#endif
-#include "printtrace.h"
-
/************************************************************************/
/* Internal data structures and functions */
/************************************************************************/
@@ -309,14 +306,4 @@ pfunc_osl_printDetailedDebugMessage SAL_CALL osl_setDetailedDebugMessageFunc (
return pOldFunc;
}
-/************************************************************************/
-/* osl_trace */
-/************************************************************************/
-void osl_trace(char const * pszFormat, ...) {
- va_list args;
- va_start(args, pszFormat);
- printTrace((unsigned long) getpid(), pszFormat, args);
- va_end(args);
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/w32/diagnose.c b/sal/osl/w32/diagnose.c
index f8fc997fff40..6e793c3cf718 100644
--- a/sal/osl/w32/diagnose.c
+++ b/sal/osl/w32/diagnose.c
@@ -29,9 +29,6 @@
#include "system.h"
#include <osl/diagnose.h>
-#include <osl/thread.h>
-
-#include "printtrace.h"
static pfunc_osl_printDebugMessage _pPrintDebugMessage = NULL;
static pfunc_osl_printDetailedDebugMessage _pPrintDetailedDebugMessage = NULL;
@@ -63,24 +60,6 @@ void SAL_CALL osl_breakDebug(void)
abort ();
}
-void osl_trace(char const * pszFormat, ...) {
- va_list args;
- va_start(args, pszFormat);
- if ( IsDebuggerPresent() )
- {
- sal_Char szMessage[512];
- int written = _vsnprintf(
- szMessage, sizeof(szMessage) - 2, pszFormat, args );
- if ( written == -1 )
- written = sizeof(szMessage) - 2;
- szMessage[ written++ ] = '\n';
- szMessage[ written ] = 0;
- OutputDebugString( szMessage );
- }
- printTrace((unsigned long) _getpid(), pszFormat, args);
- va_end(args);
-}
-
sal_Bool SAL_CALL osl_assertFailedLine(const sal_Char* pszFileName, sal_Int32 nLine, const sal_Char* pszMessage)
{
char const * env = getenv( "SAL_DIAGNOSE_ABORT" );
diff --git a/sal/rtl/source/logfile.cxx b/sal/rtl/source/logfile.cxx
index f71d8f5be689..c5858c1747b8 100644
--- a/sal/rtl/source/logfile.cxx
+++ b/sal/rtl/source/logfile.cxx
@@ -39,10 +39,12 @@
#include <osl/time.h>
#include <osl/mutex.hxx>
#include <rtl/bootstrap.h>
+#include <rtl/oustringostreaminserter.hxx>
#include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/alloc.h>
#include <rtl/instance.hxx>
+#include <sal/log.h>
#include "osl/thread.h"
#include <algorithm>
@@ -107,7 +109,8 @@ OUString getFileUrl( const OUString &name )
if ( osl_getFileURLFromSystemPath( name.pData, &aRet.pData )
!= osl_File_E_None )
{
- OSL_ASSERT( false );
+ SAL_WARN_S(
+ "sal", "osl_getFileURLFromSystemPath failed for \"" << name << '"');
}
OUString aWorkingDirectory;
@@ -182,7 +185,9 @@ void init() {
}
else
{
- OSL_TRACE( "Couldn't open logfile %s(%d)" , o.getStr(), e );
+ SAL_WARN_S(
+ "sal",
+ "Couldn't open logfile " << o << '(' << e << ')');
}
}
g_bHasBeenCalled = sal_True;
diff --git a/sal/util/sal.map b/sal/util/sal.map
index b67e313427b5..797c1a25c576 100755
--- a/sal/util/sal.map
+++ b/sal/util/sal.map
@@ -626,5 +626,6 @@ PRIVATE_1.1 {
PRIVATE_1.2 { # LibreOffice 3.5
global:
- osl_detail_formatString;
+ sal_detail_log;
+ sal_detail_logFormat;
} PRIVATE_1.1;
diff --git a/sfx2/inc/sfx2/objface.hxx b/sfx2/inc/sfx2/objface.hxx
index d867bd065f2b..7e43c19b1226 100644
--- a/sfx2/inc/sfx2/objface.hxx
+++ b/sfx2/inc/sfx2/objface.hxx
@@ -29,6 +29,8 @@
#define _SFXOBJFACE_HXX
#include "sal/config.h"
+
+#include "rtl/ustring.hxx"
#include "sfx2/dllapi.h"
#include "sal/types.h"
#include <tools/string.hxx>
@@ -79,7 +81,7 @@ public:
const char* GetClassName() const { return pName; }
int HasName() const { return 0 != aNameResId.GetId(); }
- String GetName() const
+ rtl::OUString GetName() const
{ return String(aNameResId); }
ResMgr* GetResMgr() const
{ return aNameResId.GetResMgr(); }
diff --git a/sfx2/source/appl/module.cxx b/sfx2/source/appl/module.cxx
index 6883e90f5ff5..a4fc06dea36e 100644
--- a/sfx2/source/appl/module.cxx
+++ b/sfx2/source/appl/module.cxx
@@ -50,6 +50,7 @@
#include "sfx2/taskpane.hxx"
#include <tools/diagnose_ex.h>
#include <rtl/strbuf.hxx>
+#include <sal/log.h>
#define SfxModule
#include "sfxslots.hxx"
@@ -208,7 +209,7 @@ void SfxModule::RegisterChildWindow(SfxChildWinFactory *pFact)
if (pFact->nId == (*pImpl->pFactArr)[nFactory]->nId)
{
pImpl->pFactArr->Remove( nFactory );
- OSL_FAIL("ChildWindow registered multiple times!");
+ SAL_WARN("sfx2", "ChildWindow registered multiple times!");
return;
}
}
@@ -391,11 +392,10 @@ FieldUnit SfxModule::GetModuleFieldUnit( ::com::sun::star::uno::Reference< ::com
SfxPoolItem const * pItem = pModule->GetItem( SID_ATTR_METRIC );
if ( pItem == NULL )
{
- OSL_FAIL(
- OSL_FORMAT(
- ("SfxModule::GetFieldUnit: no metric item in the module"
- " implemented by '%s'!"),
- typeid(*pModule).name()));
+ SAL_WARN_S(
+ "sfx2",
+ "SfxModule::GetFieldUnit: no metric item in the module implemented"
+ " by '" << typeid(*pModule).name() << "'!");
return FUNIT_100TH_MM;
}
return (FieldUnit)( (SfxUInt16Item*)pItem )->GetValue();
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index 9d176c43ffd2..671f79fff095 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -28,8 +28,12 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sfx2.hxx"
+#include "sal/config.h"
+
+#include <iomanip>
#include <boost/unordered_map.hpp>
+#include <sal/log.h>
#include <svl/itempool.hxx>
#include <svl/itemiter.hxx>
#include <svl/eitem.hxx>
@@ -1741,26 +1745,12 @@ sal_uInt16 SfxBindings::EnterRegistrations(const char *pFile, int nLine)
(void)pFile;
(void)nLine;
DBG_MEMTEST();
-#ifdef DBG_UTIL
- rtl::OStringBuffer aMsg;
- sal_uInt16 nSpaces = Min(nRegLevel, sal_uInt16(8));
- while (nSpaces--)
- aMsg.append(' ');
- aMsg.append(RTL_CONSTASCII_STRINGPARAM("this = "));
- aMsg.append(reinterpret_cast<sal_Int64>(this));
- aMsg.append(RTL_CONSTASCII_STRINGPARAM(" Level = "));
- aMsg.append(static_cast<sal_Int32>(nRegLevel));
- aMsg.append(RTL_CONSTASCII_STRINGPARAM(
- " SfxBindings::EnterRegistrations "));
- if (pFile)
- {
- aMsg.append(RTL_CONSTASCII_STRINGPARAM("File: "));
- aMsg.append(pFile);
- aMsg.append(RTL_CONSTASCII_STRINGPARAM(" Line: "));
- aMsg.append(static_cast<sal_Int32>(nLine));
- }
- DbgTrace(aMsg.getStr());
-#endif
+ SAL_INFO_S(
+ "sfx2",
+ std::setw(Min(nRegLevel, sal_uInt16(8))) << ' ' << "this = " << this
+ << " Level = " << nRegLevel << " SfxBindings::EnterRegistrations "
+ << (pFile
+ ? SAL_STREAM("File: " << pFile << " Line: " << nLine) : ""));
// When bindings are locked, also lock sub bindings.
if ( pImp->pSubBindings )
@@ -1858,26 +1848,12 @@ void SfxBindings::LeaveRegistrations( sal_uInt16 nLevel, const char *pFile, int
}
}
-#ifdef DBG_UTIL
- rtl::OStringBuffer aMsg;
- sal_uInt16 nSpaces = Min(nRegLevel, sal_uInt16(8));
- while (nSpaces--)
- aMsg.append(' ');
- aMsg.append(RTL_CONSTASCII_STRINGPARAM("this = "));
- aMsg.append(reinterpret_cast<sal_Int64>(this));
- aMsg.append(RTL_CONSTASCII_STRINGPARAM(" Level = "));
- aMsg.append(static_cast<sal_Int32>(nRegLevel));
- aMsg.append(RTL_CONSTASCII_STRINGPARAM(
- " SfxBindings::LeaveRegistrations "));
- if (pFile)
- {
- aMsg.append(RTL_CONSTASCII_STRINGPARAM("File: "));
- aMsg.append(pFile);
- aMsg.append(RTL_CONSTASCII_STRINGPARAM(" Line: "));
- aMsg.append(static_cast<sal_Int32>(nLine));
- }
- DbgTrace(aMsg.getStr());
-#endif
+ SAL_INFO_S(
+ "sfx2",
+ std::setw(Min(nRegLevel, sal_uInt16(8))) << ' ' << "this = " << this
+ << " Level = " << nRegLevel << " SfxBindings::LeaveRegistrations "
+ << "File: " << (pFile ? pFile : "--") << " Line: "
+ << (pFile ? nLine : 0));
}
//--------------------------------------------------------------------
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index 8df3b4a00a6a..c26229146af0 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -476,25 +476,13 @@ void SfxDispatcher::Pop
SfxApplication *pSfxApp = SFX_APP();
-#ifdef DBG_UTIL
- rtl::OStringBuffer aMsg(RTL_CONSTASCII_STRINGPARAM("-SfxDispatcher("));
- aMsg.append(reinterpret_cast<sal_Int64>(this));
- if (bPush)
- aMsg.append(RTL_CONSTASCII_STRINGPARAM(")::Push("));
- else
- aMsg.append(RTL_CONSTASCII_STRINGPARAM(")::Pop("));
- if (rShell.GetInterface())
- aMsg.append(rShell.GetInterface()->GetClassName());
- else
- aMsg.append(reinterpret_cast<sal_Int64>(&rShell));
- if (bDelete)
- aMsg.append(RTL_CONSTASCII_STRINGPARAM(") with delete"));
- else
- aMsg.append(')');
- if (bUntil)
- aMsg.append(RTL_CONSTASCII_STRINGPARAM(" (up to)"));
- DbgTrace(aMsg.getStr());
-#endif
+ SAL_INFO_S(
+ "sfx2",
+ "-SfxDispatcher(" << this << (bPush ? ")::Push(" : ")::Pop(")
+ << (rShell.GetInterface()
+ ? rShell.GetInterface()->GetClassName() : SAL_STREAM(&rShell))
+ << (bDelete ? ") with delete" : ")")
+ << (bUntil ? " (up to)" : ""));
// same shell as on top of the to-do stack?
if ( pImp->aToDoStack.Count() && pImp->aToDoStack.Top().pCluster == &rShell )
@@ -1705,12 +1693,6 @@ void SfxDispatcher::FlushImpl()
OSL_TRACE("Flushing dispatcher!");
-#ifdef DBG_UTIL
- rtl::OStringBuffer aMsg(RTL_CONSTASCII_STRINGPARAM("SfxDispatcher("));
- aMsg.append(reinterpret_cast<sal_Int64>(this));
- aMsg.append(RTL_CONSTASCII_STRINGPARAM(")::Flush()"));
-#endif
-
pImp->aTimer.Stop();
if ( pImp->pParent )
@@ -1821,10 +1803,7 @@ void SfxDispatcher::FlushImpl()
for (sal_uInt16 n=0; n<SFX_OBJECTBAR_MAX; n++)
pImp->aFixedObjBars[n].nResId = 0;
-#ifdef DBG_UTIL
- aMsg.append(RTL_CONSTASCII_STRINGPARAM("done"));
- DbgTrace(aMsg.getStr());
-#endif
+ SAL_INFO_S("sfx2", "SfxDispatcher(" << this << ")::Flush() done");
}
//--------------------------------------------------------------------
diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx
index 7a32326ad652..33a6f47e0c18 100644
--- a/sfx2/source/control/shell.cxx
+++ b/sfx2/source/control/shell.cxx
@@ -31,6 +31,8 @@
#include <com/sun/star/embed/VerbDescriptor.hpp>
#include <com/sun/star/embed/VerbAttributes.hpp>
#include <basic/sbstar.hxx>
+#include <rtl/oustringostreaminserter.hxx>
+#include <sal/log.h>
#include <svl/itempool.hxx>
#include <svl/undo.hxx>
#include <svtools/itemdel.hxx>
@@ -623,15 +625,10 @@ void SfxShell::DoActivate_Impl( SfxViewFrame *pFrame, sal_Bool bMDI )
if ( !p_IF )
return;
#endif
-#ifdef DBG_UTIL_VB
- String aMsg("SfxShell::DoActivate() ");
- aMsg += (long)this;
- aMsg += " ";
- aMsg += GetInterface()->GetName();
- aMsg += " bMDI ";
- if ( bMDI ) aMsg += "MDI";
- DbgTrace( aMsg.GetBuffer() );
-#endif
+ SAL_INFO_S(
+ "sfx2.vb",
+ "SfxShell::DoActivate() " << this << " " << GetInterface()->GetName()
+ << " bMDI " << (bMDI ? "MDI" : ""));
if ( bMDI )
{
@@ -664,15 +661,10 @@ void SfxShell::DoDeactivate_Impl( SfxViewFrame *pFrame, sal_Bool bMDI )
if ( !p_IF )
return;
#endif
-#ifdef DBG_UTIL_VB
- String aMsg("SfxShell::DoDeactivate()");
- aMsg += (long)this;
- aMsg += " ";
- aMsg += GetInterface()->GetName();
- aMsg += " bMDI ";
- if ( bMDI ) aMsg += "MDI";
- DbgTrace( aMsg.GetBuffer() );
-#endif
+ SAL_INFO_S(
+ "sfx2.vb",
+ "SfxShell::DoDeactivate()" << this << " " << GetInterface()->GetName()
+ << " bMDI " << (bMDI ? "MDI" : ""));
// Only when it comes from a Frame
// (not when for instance by poping BASIC-IDE from AppDisp)
diff --git a/smoketestoo_native/smoketest.cxx b/smoketestoo_native/smoketest.cxx
index f59e03a4dafa..b0a709761f2f 100644
--- a/smoketestoo_native/smoketest.cxx
+++ b/smoketestoo_native/smoketest.cxx
@@ -57,11 +57,11 @@
#include "osl/conditn.hxx"
#include "osl/diagnose.h"
#include "osl/time.h"
+#include "rtl/oustringostreaminserter.hxx"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "unotest/gettestargument.hxx"
#include "unotest/officeconnection.hxx"
-#include "unotest/oustringostreaminserter.hxx"
#include "unotest/toabsolutefileurl.hxx"
namespace {
diff --git a/solenv/bin/addsym.awk b/solenv/bin/addsym.awk
index de0b57934f7f..4c18bdc53847 100644
--- a/solenv/bin/addsym.awk
+++ b/solenv/bin/addsym.awk
@@ -36,9 +36,14 @@ END {
print "# Weak RTTI symbols for C++ exceptions:"
print "UDK_3_0_0 {"
print "global:"
- print "_ZTI*; _ZTS*; # weak RTTI symbols for C++ exceptions"
+ print "_ZTI*; _ZTS*;"
print "};"
}
+ print "# Unique libstdc++ symbols:"
+ print "GLIBCXX_3.4 {"
+ print "global:"
+ print "_ZGVNSt7num_put*; _ZNSt7num_put*;"
+ print "};"
}
state == 2 {
print "_ZTI*; _ZTS*; # weak RTTI symbols for C++ exceptions"
diff --git a/solenv/gbuild/gbuild.mk b/solenv/gbuild/gbuild.mk
index 4634333cd49f..361632ea1f6c 100644
--- a/solenv/gbuild/gbuild.mk
+++ b/solenv/gbuild/gbuild.mk
@@ -212,11 +212,17 @@ gb_GLOBALDEFS += \
-DOPTIMIZE \
-DNDEBUG \
-else ifneq ($(gb_DEBUGLEVEL),1) # 2 or more
+else
+gb_GLOBALDEFS += \
+ -DSAL_LOG_INFO \
+ -DSAL_LOG_WARN \
+
+ifneq ($(gb_DEBUGLEVEL),1) # 2 or more
gb_GLOBALDEFS += \
-DDEBUG \
endif
+endif
ifneq ($(strip $(ENABLE_GTK)),)
gb_GLOBALDEFS += -DENABLE_GTK
diff --git a/solenv/inc/settings.mk b/solenv/inc/settings.mk
index 5c6f6cc488aa..5eb6dbf63e45 100644
--- a/solenv/inc/settings.mk
+++ b/solenv/inc/settings.mk
@@ -1138,6 +1138,9 @@ RSCDEFS+= -DNDEBUG
.IF "$(DBG_LEVEL)"!=""
CDEFS+=-DOSL_DEBUG_LEVEL=$(DBG_LEVEL)
RSCDEFS+=-DOSL_DEBUG_LEVEL=$(DBG_LEVEL)
+.IF "$(DBG_LEVEL)"!="0"
+CDEFS+=-DSAL_LOG_INFO -DSAL_LOG_WARN
+.ENDIF
.ENDIF
.IF "$(optimize)"!=""
diff --git a/svl/source/inc/poolio.hxx b/svl/source/inc/poolio.hxx
index 1515779d33ed..15f55eebdb72 100644
--- a/svl/source/inc/poolio.hxx
+++ b/svl/source/inc/poolio.hxx
@@ -154,17 +154,8 @@ struct SfxItemPool_Impl
#endif
#if defined(DBG_UTIL) && defined(MSC)
-#define SFX_TRACE(s,p) \
- { \
- ByteString aPtr(RTL_CONSTASCII_STRINGPARAM("0x0000:0x0000")); \
- _snprintf(const_cast< sal_Char *>(aPtr.GetBuffer()), aPtr.Len(), \
- "%lp", p ); \
- aPtr.Insert(s, 0); \
- DbgTrace( aPtr.GetBuffer() ); \
- }
#define DBG(x) x
#else
-#define SFX_TRACE(s,p)
#define DBG(x)
#endif
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index 2bcef79a1bfc..cdcf217b1467 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -836,7 +836,6 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem )
else
{
SFX_ASSERT( 0, rItem.Which(), "removing Item without ref" );
- SFX_TRACE( "to be removed, but not no refs: ", p );
}
// ggf. kleinstmoegliche freie Position merken
@@ -854,7 +853,6 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem )
// nicht vorhanden
SFX_ASSERT( 0, rItem.Which(), "removing Item not in Pool" );
- SFX_TRACE( "to be removed, but not in pool: ", &rItem );
}
// -----------------------------------------------------------------------
diff --git a/svl/source/items/poolio.cxx b/svl/source/items/poolio.cxx
index eb84af50e9d1..ce5bb32b7db4 100644
--- a/svl/source/items/poolio.cxx
+++ b/svl/source/items/poolio.cxx
@@ -32,6 +32,7 @@
#include <string.h>
#include <stdio.h>
+#include <sal/log.h>
#include <tools/solar.h>
#include <svl/itempool.hxx>
#include "whassert.hxx"
@@ -955,14 +956,12 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
delete rpNewItem;
rpNewItem = pOldItem;
bFound = true;
- SFX_TRACE( "reusing item", pOldItem );
+ SAL_INFO_S("svl", "reusing item" << pOldItem);
break;
}
}
- if ( !bFound )
- {
- SFX_TRACE( "item not found: ", pOldItem );
- }
+ SAL_INFO_IF_S(
+ !bFound, "svl", "item not found: " << pOldItem);
}
}
}
diff --git a/svl/source/items/whassert.hxx b/svl/source/items/whassert.hxx
index 379d4794458d..d994f0d33f66 100644
--- a/svl/source/items/whassert.hxx
+++ b/svl/source/items/whassert.hxx
@@ -28,29 +28,12 @@
#ifndef _SFX_WHASSERT_HXX
#define _SFX_WHASSERT_HXX
-#include <tools/debug.hxx>
-#include <rtl/strbuf.hxx>
+#include "sal/config.h"
-//------------------------------------------------------------------------
-
-#ifdef DBG_UTIL
-#define SFX_ASSERT( bCondition, nId, sMessage ) \
-{ \
- if ( DbgIsAssert() ) \
- { \
- if ( !(bCondition) ) \
- { \
- rtl::OStringBuffer aMsg(sMessage); \
- aMsg.append(RTL_CONSTASCII_STRINGPARAM("\nwith Id/Pos: ")); \
- aMsg.append(static_cast<sal_Int32>(nId)); \
- DbgError(aMsg.getStr(), __FILE__, __LINE__); \
- } \
- } \
-}
-#else
-#define SFX_ASSERT( bCondition, nId, sMessage )
-#endif
+#include "sal/log.h"
+#define SFX_ASSERT( bCondition, nId, sMessage ) SAL_WARN_IF_S( \
+ !(bCondition), "svl", (sMessage) << ", with ID/pos " << (nId));
#endif
diff --git a/sw/source/ui/docvw/srcedtw.cxx b/sw/source/ui/docvw/srcedtw.cxx
index b80904fa2a03..04adab9ac1d4 100644
--- a/sw/source/ui/docvw/srcedtw.cxx
+++ b/sw/source/ui/docvw/srcedtw.cxx
@@ -33,7 +33,9 @@
#include <hintids.hxx>
#include <cmdid.h>
-
+#include <rtl/oustringostreaminserter.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/log.h>
#include <svtools/textview.hxx>
#include <svx/svxids.hrc>
#include <vcl/scrbar.hxx>
@@ -161,10 +163,10 @@ static void lcl_Highlight(const String& rSource, SwTextPortions& aPortionList)
else
{
// what was that?
-#if OSL_DEBUG_LEVEL > 1
- OSL_FAIL(OSL_FORMAT("Token %s not recognised!",
- rtl::OUStringToOString(sToken, osl_getThreadTextEncoding()).getStr()));
-#endif
+ SAL_WARN_S(
+ "sw.level2",
+ "Token " << rtl::OUString(sToken)
+ << " not recognised!");
}
}
@@ -539,7 +541,7 @@ IMPL_LINK(SwSrcEditWindow, ScrollHdl, ScrollBar*, pScroll)
IMPL_LINK( SwSrcEditWindow, SyntaxTimerHdl, Timer *, pTimer )
{
Time aSyntaxCheckStart;
- OSL_ENSURE( pTextView, "Noch keine View, aber Syntax-Highlight ?!" );
+ SAL_WARN_IF(pTextView == 0, "sw", "No View yet, but syntax highlighting?!");
bHighlighting = sal_True;
sal_uInt16 nLine;
@@ -665,10 +667,9 @@ void SwSrcEditWindow::ImpDoHighlight( const String& rSource, sal_uInt16 nLineOff
for ( size_t i = 0; i < nCount; i++ )
{
SwTextPortion& r = aPortionList[i];
-#if OSL_DEBUG_LEVEL > 1
- sal_uInt16 nLine = aPortionList[0].nLine;
- OSL_ENSURE( r.nLine == nLine, "doch mehrere Zeilen ?" );
-#endif
+ SAL_WARN_IF(
+ r.nLine != aPortionList[0].nLine, "sw.level2",
+ "multiple lines after all?");
if ( r.nStart > r.nEnd ) // only until Bug from MD is resolved
continue;
diff --git a/tools/inc/tools/debug.hxx b/tools/inc/tools/debug.hxx
index 3d75f94437cd..95b320979913 100644
--- a/tools/inc/tools/debug.hxx
+++ b/tools/inc/tools/debug.hxx
@@ -31,9 +31,24 @@
#include "tools/toolsdllapi.h"
+#include <sal/log.h>
#include <sal/types.h>
#include <tools/solar.h>
+/** The facilities provided by this header are deprecated. True assertions
+ (that detect broken program logic) should use standard assert (which aborts
+ 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.
+
+ Because the assertion macros (DBG_ASSERTWARNING, DBG_ASSERT, DBG_BF_ASSERT)
+ have been used for true assertions as well as for logged warnings, they map
+ to SAL_WARN instead of standard assert. The warning and error macros
+ (DBG_WARNING, DBG_WARNING1, ..., DBG_WARNING5, DBG_WARNINGFILE,
+ DBG_ERRORFILE) all map to SAL_WARN, too.
+*/
+
// ------------
// - DBG_UITL -
// ------------
@@ -348,24 +363,6 @@ TOOLS_DLLPUBLIC void DbgOutTypef( sal_uInt16 nOutType, const sal_Char* pFStr, ..
TOOLS_DLLPUBLIC void DbgOutf( const sal_Char* pFStr, ... );
TOOLS_DLLPUBLIC void ImpDbgOutfBuf( sal_Char* pBuf, const sal_Char* pFStr, ... );
-inline void DbgTrace( const sal_Char* pMsg,
- const sal_Char* pFile = NULL, sal_uInt16 nLine = 0 )
-{
- DbgOut( pMsg, DBG_OUT_TRACE, pFile, nLine );
-}
-
-inline void DbgWarning( const sal_Char* pMsg,
- const sal_Char* pFile = NULL, sal_uInt16 nLine = 0 )
-{
- DbgOut( pMsg, DBG_OUT_WARNING, pFile, nLine );
-}
-
-inline void DbgError( const sal_Char* pMsg,
- const sal_Char* pFile = NULL, sal_uInt16 nLine = 0 )
-{
- DbgOut( pMsg, DBG_OUT_ERROR, pFile, nLine );
-}
-
// --- Dbg-Test-Functions ---
inline void DbgMemTest( void* p = NULL )
@@ -469,110 +466,34 @@ public:
DbgXtor( DBG_FUNC( aName ), DBG_XTOR_CHKOBJ, \
(const void*)pObj, (DbgUsr)fTest )
-#define DBG_ASSERTWARNING( sCon, aWarning ) \
-do \
-{ \
- if ( DbgIsAssertWarning() ) \
- { \
- if ( !( sCon ) ) \
- { \
- DbgWarning( aWarning, __FILE__, \
- __LINE__ ); \
- } \
- } \
-} while(0)
+#define DBG_ASSERTWARNING( sCon, aWarning ) \
+ SAL_WARN_IF(!(sCon), "legacy.tools", aWarning)
-#define DBG_ASSERT( sCon, aError ) \
-do \
-{ \
- if ( DbgIsAssert() ) \
- { \
- if ( !( sCon ) ) \
- { \
- DbgError( aError, \
- __FILE__, __LINE__ ); \
- } \
- } \
-} while(0)
+#define DBG_ASSERT( sCon, aError ) \
+ SAL_WARN_IF(!(sCon), "legacy.tools", aError)
#ifdef DBG_BINFILTER
-#define DBG_BF_ASSERT( sCon, aError ) \
-do \
-{ \
- if ( !( sCon ) ) \
- { \
- DbgError( aError, \
- __FILE__, __LINE__ ); \
- } \
-} while(0)
+#define DBG_BF_ASSERT( sCon, aError ) \
+ SAL_WARN_IF(!(sCon), "legacy.binfilter", aError)
#else
#define DBG_BF_ASSERT( sCon, aError ) ((void)0)
#endif
-#define DBG_WARNING( aWarning ) \
-do \
-{ \
- if ( DbgIsWarningOut() ) \
- DbgWarning( aWarning ); \
-} while(0)
-#define DBG_WARNING1( aWarning, x1 ) \
-do \
-{ \
- if ( DbgIsWarningOut() ) \
- { \
- DbgOutTypef( DBG_OUT_WARNING, aWarning, \
- x1 ); \
- } \
-} while(0)
-#define DBG_WARNING2( aWarning, x1, x2 ) \
-do \
-{ \
- if ( DbgIsWarningOut() ) \
- { \
- DbgOutTypef( DBG_OUT_WARNING, aWarning, \
- x1, x2 ); \
- } \
-} while(0)
-#define DBG_WARNING3( aWarning, x1, x2, x3 ) \
-do \
-{ \
- if ( DbgIsWarningOut() ) \
- { \
- DbgOutTypef( DBG_OUT_WARNING, aWarning, \
- x1, x2, x3 ); \
- } \
-} while(0)
-#define DBG_WARNING4( aWarning, x1, x2, x3, x4 ) \
-do \
-{ \
- if ( DbgIsWarningOut() ) \
- { \
- DbgOutTypef( DBG_OUT_WARNING, aWarning, \
- x1, x2, x3, x4 ); \
- } \
-} while(0)
-#define DBG_WARNING5( aWarning, x1, x2, x3, x4, x5 )\
-do \
-{ \
- if ( DbgIsWarningOut() ) \
- { \
- DbgOutTypef( DBG_OUT_WARNING, aWarning, \
- x1, x2, x3, x4, x5 ); \
- } \
-} while(0)
-#define DBG_WARNINGFILE( aWarning ) \
-do \
-{ \
- if ( DbgIsWarningOut() ) \
- DbgWarning( aWarning, __FILE__, __LINE__ ); \
-} while(0)
-
-#define DBG_ERRORFILE( aError ) \
-do \
-{ \
- if ( DbgIsErrorOut() ) \
- DbgError( aError, __FILE__, __LINE__ ); \
-} while(0)
+#define DBG_WARNING( aWarning ) SAL_WARN("legacy.tools", aWarning)
+#define DBG_WARNING1( aWarning, x1 ) SAL_WARN("legacy.tools", aWarning, x1)
+#define DBG_WARNING2( aWarning, x1, x2 ) \
+ SAL_WARN("legacy.tools", aWarning, x1, x2)
+#define DBG_WARNING3( aWarning, x1, x2, x3 ) \
+ SAL_WARN("legacy.tools", aWarning, x1, x2, x3)
+#define DBG_WARNING4( aWarning, x1, x2, x3, x4 ) \
+ SAL_WARN("legacy.tools", aWarning, x1, x2, x3, x4)
+#define DBG_WARNING5( aWarning, x1, x2, x3, x4, x5 ) \
+ SAL_WARN("legacy.tools", aWarning, x1, x2, x3, x4, x5)
+#define DBG_WARNINGFILE( aWarning ) \
+ SAL_WARN("legacy.tools", aWarning, __FILE__, __LINE__)
+
+#define DBG_ERRORFILE( aError ) \
+ SAL_WARN("legacy.tools", aError, __FILE__, __LINE__)
#define DBG_TESTSOLARMUTEX() \
do \
diff --git a/tools/qa/cppunit/test_reversemap.cxx b/tools/qa/cppunit/test_reversemap.cxx
index 190b4b2c10f4..caaa6d2d1565 100644
--- a/tools/qa/cppunit/test_reversemap.cxx
+++ b/tools/qa/cppunit/test_reversemap.cxx
@@ -38,11 +38,11 @@
#include "cppunit/TestFixture.h"
#include "cppunit/extensions/HelperMacros.h"
#include "cppunit/plugin/TestPlugIn.h"
+#include "rtl/oustringostreaminserter.hxx"
#include <rtl/ustring.hxx>
#include <vector>
#include "tools/tenccvt.hxx"
-#include "unotest/oustringostreaminserter.hxx"
//Tests for getBestMSEncodingByChar
diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx
index b2b6367ca734..d3f2c088b897 100644
--- a/tools/source/debug/debug.cxx
+++ b/tools/source/debug/debug.cxx
@@ -50,6 +50,7 @@
#include <tools/debug.hxx>
#include <rtl/string.h>
+#include <sal/log.h>
#include <sal/macros.h>
#include <vector>
@@ -60,22 +61,6 @@
#ifdef DBG_UTIL
-// --- DbgErrors ---
-
-static sal_Char const DbgError_ProfEnd1[] = "DBG_PROF...() without DBG_PROFSTART(): ";
-static sal_Char const DbgError_Xtor1[] = "DBG_DTOR() or DBG_CHKTHIS() without DBG_CTOR(): ";
-
-static sal_Char const DbgError_CtorDtor1[] = "this == NULL in class ";
-static sal_Char const DbgError_CtorDtor2[] = "invalid this-Pointer %p in class ";
-static sal_Char const DbgError_CtorDtor3[] = "Error-Msg from Object %p in class ";
-
-static sal_Char const DbgTrace_EnterCtor[] = "Enter Ctor from class ";
-static sal_Char const DbgTrace_LeaveCtor[] = "Leave Ctor from class ";
-static sal_Char const DbgTrace_EnterDtor[] = "Enter Dtor from class ";
-static sal_Char const DbgTrace_LeaveDtor[] = "Leave Dtor from class ";
-static sal_Char const DbgTrace_EnterMeth[] = "Enter method from class ";
-static sal_Char const DbgTrace_LeaveMeth[] = "Leave method from class ";
-
// --- PointerList ---
#define PBLOCKCOUNT 1024
@@ -1345,14 +1330,13 @@ void DbgProf( sal_uInt16 nAction, DbgDataType* pDbgData )
if ( !(pData->aDbgData.nTestFlags & DBG_TEST_PROFILING) )
return;
- sal_Char aBuf[DBG_BUF_MAXLEN];
ProfType* pProfData = (ProfType*)pDbgData->pData;
sal_uIntPtr nTime;
if ( (nAction != DBG_PROF_START) && !pProfData )
{
- strcpy( aBuf, DbgError_ProfEnd1 );
- strcat( aBuf, pDbgData->pName );
- DbgError( aBuf );
+ SAL_WARN_S(
+ "tools.debug",
+ "DBG_PROF...() without DBG_PROFSTART(): " << pDbgData->pName);
return;
}
@@ -1387,7 +1371,8 @@ void DbgProf( sal_uInt16 nAction, DbgDataType* pDbgData )
if ( pProfData->nStart == 0xFFFFFFFF )
{
- DbgError( DbgError_ProfEnd1 );
+ SAL_WARN(
+ "tools.debug", "DBG_PROF...() without DBG_PROFSTART()");
return;
}
@@ -1467,25 +1452,15 @@ void DbgXtor( DbgDataType* pDbgData, sal_uInt16 nAction, const void* pThis,
if ( !pXtorData->bTest )
return;
- sal_Char aBuf[DBG_BUF_MAXLEN];
sal_uInt16 nAct = nAction & ~DBG_XTOR_DTOROBJ;
- // Trace (Enter)
- if ( (pData->aDbgData.nTestFlags & DBG_TEST_XTOR_TRACE) &&
- !(nAction & DBG_XTOR_DTOROBJ) )
- {
- if ( nAct != DBG_XTOR_CHKOBJ )
- {
- if ( nAct == DBG_XTOR_CTOR )
- strcpy( aBuf, DbgTrace_EnterCtor );
- else if ( nAct == DBG_XTOR_DTOR )
- strcpy( aBuf, DbgTrace_EnterDtor );
- else
- strcpy( aBuf, DbgTrace_EnterMeth );
- strcat( aBuf, pDbgData->pName );
- DbgTrace( aBuf );
- }
- }
+ SAL_INFO_IF_S(
+ ((pData->aDbgData.nTestFlags & DBG_TEST_XTOR_TRACE)
+ && !(nAction & DBG_XTOR_DTOROBJ) && nAct != DBG_XTOR_CHKOBJ),
+ "tools.debug",
+ (nAct == DBG_XTOR_CTOR ? "Enter Ctor from class "
+ : nAct == DBG_XTOR_DTOR ? "Enter Dtor from class "
+ : "Enter method from class ") << pDbgData->pName);
// Sind noch Xtor-Tests als Trace an
if ( pData->aDbgData.nTestFlags & DBG_TEST_XTOR_EXTRA )
@@ -1493,9 +1468,10 @@ void DbgXtor( DbgDataType* pDbgData, sal_uInt16 nAction, const void* pThis,
// DBG_CTOR-Aufruf vor allen anderen DBG_XTOR-Aufrufen
if ( ((nAction & ~DBG_XTOR_DTOROBJ) != DBG_XTOR_CTOR) && !pDbgData->pData )
{
- strcpy( aBuf, DbgError_Xtor1 );
- strcat( aBuf, pDbgData->pName );
- DbgError( aBuf );
+ SAL_WARN_S(
+ "tools.debug",
+ "DBG_DTOR() or DBG_CHKTHIS() without DBG_CTOR(): "
+ << pDbgData->pName);
return;
}
@@ -1508,20 +1484,17 @@ void DbgXtor( DbgDataType* pDbgData, sal_uInt16 nAction, const void* pThis,
// This-Pointer == NULL
if ( !pThis )
{
- strcpy( aBuf, DbgError_CtorDtor1 );
- strcat( aBuf, pDbgData->pName );
- DbgError( aBuf );
+ SAL_WARN_S(
+ "tools.debug",
+ "this == NULL in class " << pDbgData->pName);
return;
}
if ( (nAction & ~DBG_XTOR_DTOROBJ) != DBG_XTOR_CTOR )
{
- if ( !pXtorData->aThisList.IsIn( pThis ) )
- {
- sprintf( aBuf, DbgError_CtorDtor2, pThis );
- strcat( aBuf, pDbgData->pName );
- DbgError( aBuf );
- }
+ SAL_WARN_IF_S(
+ !pXtorData->aThisList.IsIn(pThis), "tools.debug",
+ "invalid this-Pointer %p in class " << pDbgData->pName);
}
}
}
@@ -1585,32 +1558,21 @@ void DbgXtor( DbgDataType* pDbgData, sal_uInt16 nAction, const void* pThis,
}
// Gegebenenfalls Fehlermeldung ausgeben
- if ( pMsg )
- {
- sprintf( aBuf, DbgError_CtorDtor3, pThis );
- strcat( aBuf, pDbgData->pName );
- strcat( aBuf, ": \n" );
- strcat( aBuf, pMsg );
- DbgError( aBuf );
- }
+ SAL_WARN_IF_S(
+ pMsg, "tools.debug",
+ "Error-Msg from Object " << pThis << " in class "
+ << pDbgData->pName << ": " << pMsg);
}
- // Trace (Leave)
- if ( (pData->aDbgData.nTestFlags & DBG_TEST_XTOR_TRACE) &&
- (nAction & DBG_XTOR_DTOROBJ) )
- {
- if ( nAct != DBG_XTOR_CHKOBJ )
- {
- if ( nAct == DBG_XTOR_CTOR )
- strcpy( aBuf, DbgTrace_LeaveCtor );
- else if ( nAct == DBG_XTOR_DTOR )
- strcpy( aBuf, DbgTrace_LeaveDtor );
- else
- strcpy( aBuf, DbgTrace_LeaveMeth );
- strcat( aBuf, pDbgData->pName );
- DbgTrace( aBuf );
- }
- }
+ SAL_INFO_IF_S(
+ ((pData->aDbgData.nTestFlags & DBG_TEST_XTOR_TRACE)
+ && (nAction & DBG_XTOR_DTOROBJ) && nAct != DBG_XTOR_CHKOBJ),
+ "tools.debug",
+ (nAct == DBG_XTOR_CTOR
+ ? "Leave Ctor from class "
+ : nAct == DBG_XTOR_DTOR
+ ? "Leave Dtor from class "
+ : "Leave method from class ") << pDbgData->pName);
}
// -----------------------------------------------------------------------
diff --git a/tools/source/rc/resmgr.cxx b/tools/source/rc/resmgr.cxx
index 1733e6e1d1ae..2ea66b2dce7d 100644
--- a/tools/source/rc/resmgr.cxx
+++ b/tools/source/rc/resmgr.cxx
@@ -43,8 +43,10 @@
#include <osl/file.hxx>
#include <osl/mutex.hxx>
#include <osl/signal.h>
+#include <rtl/oustringostreaminserter.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/strbuf.hxx>
+#include <sal/log.h>
#include <tools/urlobj.hxx>
#include <rtl/instance.hxx>
#include <rtl/bootstrap.hxx>
@@ -947,11 +949,7 @@ void ResMgr::Init( const OUString& rFileName )
InternalResMgr::FreeGlobalRes( aResHandle, pVoid );
else
{
- rtl::OStringBuffer aStr(
- RTL_CONSTASCII_STRINGPARAM("Wrong version:\n"));
- aStr.append(rtl::OUStringToOString(pImpRes->aFileName,
- RTL_TEXTENCODING_UTF8));
- DbgError(aStr.getStr());
+ SAL_WARN_S("tools", "Wrong version: " << pImpRes->aFileName);
}
}
#endif
diff --git a/unotest/prj/d.lst b/unotest/prj/d.lst
index 7b849242f1be..37fbe17f5c79 100644
--- a/unotest/prj/d.lst
+++ b/unotest/prj/d.lst
@@ -14,7 +14,6 @@ mkdir: %_DEST%\inc\unotest\detail
..\inc\unotest\filters-test.hxx %_DEST%\inc\unotest\filters-test.hxx
..\inc\unotest\gettestargument.hxx %_DEST%\inc\unotest\gettestargument.hxx
..\inc\unotest\officeconnection.hxx %_DEST%\inc\unotest\officeconnection.hxx
-..\inc\unotest\oustringostreaminserter.hxx %_DEST%\inc\unotest\oustringostreaminserter.hxx
..\inc\unotest\toabsolutefileurl.hxx %_DEST%\inc\unotest\toabsolutefileurl.hxx
..\inc\unotest\uniquepipename.hxx %_DEST%\inc\unotest\uniquepipename.hxx
..\%__SRC%\class\test.jar %_DEST%\bin\test.jar
diff --git a/vcl/source/app/dbggui.cxx b/vcl/source/app/dbggui.cxx
index 468e7c87ae65..126c56cadd77 100755
--- a/vcl/source/app/dbggui.cxx
+++ b/vcl/source/app/dbggui.cxx
@@ -39,6 +39,7 @@
#include <limits.h>
#include "tools/debug.hxx"
+#include "sal/log.h"
#include "vcl/svapp.hxx"
#include "vcl/event.hxx"
@@ -1454,10 +1455,12 @@ void DbgDialogTest( Window* pWindow )
if ( bButton )
{
- if ( !bOKCancelButton )
- DbgError( "Dialogs should have a OK- or CancelButton" );
- if ( !bDefPushButton )
- DbgError( "Dialogs should have a Button with WB_DEFBUTTON" );
+ SAL_WARN_IF(
+ !bOKCancelButton, "vcl",
+ "Dialogs should have a OK- or CancelButton");
+ SAL_WARN_IF(
+ !bDefPushButton, "vcl",
+ "Dialogs should have a Button with WB_DEFBUTTON");
}
}
@@ -1626,15 +1629,12 @@ void DbgDialogTest( Window* pWindow )
}
}
- if ( pChild->GetType() == WINDOW_MULTILINEEDIT )
- {
- if ( ( 0 == ( pChild->GetStyle() & WB_IGNORETAB ) )
- && ( 0 == ( pChild->GetStyle() & WB_READONLY ) )
- )
- {
- DbgError( "editable MultiLineEdits in Dialogs should have the Style WB_IGNORETAB" );
- }
- }
+ SAL_WARN_IF(
+ (pChild->GetType() == WINDOW_MULTILINEEDIT
+ && (pChild->GetStyle() & (WB_IGNORETAB | WB_READONLY)) == 0),
+ "vcl",
+ ("editable MultiLineEdits in Dialogs should have the Style"
+ " WB_IGNORETAB"));
if ( (pChild->GetType() == WINDOW_RADIOBUTTON) ||
(pChild->GetType() == WINDOW_IMAGERADIOBUTTON) ||