2 // **********************************************************************
4 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
6 // This copy of Ice is licensed to you under the terms described in the
7 // ICE_LICENSE file included in this distribution.
9 // **********************************************************************
11 #include <Ice/LoggerUtil.h>
12 #include <Ice/Logger.h>
13 #include <Ice/Plugin.h>
14 #include <Ice/LocalException.h>
15 #include <Ice/Instance.h>
19 namespace IceUtilInternal
22 extern bool ICE_DECLSPEC_IMPORT printStackTraces
;
27 Ice::LoggerOutputBase::__str()
32 Ice::LoggerOutputBase
&
33 Ice::operator<<(Ice::LoggerOutputBase
& out
, ios_base
& (*val
)(ios_base
&))
39 Ice::LoggerOutputBase
&
40 Ice::operator<<(Ice::LoggerOutputBase
& out
, const std::exception
& ex
)
43 if(IceUtilInternal::printStackTraces
)
45 const ::IceUtil::Exception
* exception
= dynamic_cast<const ::IceUtil::Exception
*>(&ex
);
48 out
.__str() << exception
->what() << '\n' << exception
->ice_stackTrace();
53 out
.__str() << ex
.what();
57 Ice::Print::Print(const LoggerPtr
& logger
) :
70 string s
= __str().str();
78 Ice::Warning::Warning(const LoggerPtr
& logger
) :
83 Ice::Warning::~Warning()
91 string s
= __str().str();
99 Ice::Error::Error(const LoggerPtr
& logger
) :
112 string s
= __str().str();
120 Ice::Trace::Trace(const LoggerPtr
& logger
, const string
& category
) :
134 string s
= __str().str();
137 _logger
->trace(_category
, s
);
142 Ice::LoggerPlugin::LoggerPlugin(const CommunicatorPtr
& communicator
, const LoggerPtr
& logger
)
144 if(communicator
== 0)
146 throw PluginInitializationException(__FILE__
, __LINE__
, "Communicator cannot be null");
151 throw PluginInitializationException(__FILE__
, __LINE__
, "Logger cannot be null");
154 IceInternal::InstancePtr instance
= IceInternal::getInstance(communicator
);
155 instance
->setLogger(logger
);
159 Ice::LoggerPlugin::initialize()
164 Ice::LoggerPlugin::destroy()