summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/LoggerI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/Ice/LoggerI.cpp')
-rw-r--r--cpp/src/Ice/LoggerI.cpp28
1 files changed, 12 insertions, 16 deletions
diff --git a/cpp/src/Ice/LoggerI.cpp b/cpp/src/Ice/LoggerI.cpp
index bc43d0aa9ff..2396b4cf8c3 100644
--- a/cpp/src/Ice/LoggerI.cpp
+++ b/cpp/src/Ice/LoggerI.cpp
@@ -13,11 +13,8 @@
#include <IceUtil/Mutex.h>
#include <IceUtil/MutexPtrLock.h>
-#ifdef _WIN32
-# include <IceUtil/ScopedArray.h>
-#endif
-
#include <Ice/LocalException.h>
+#include <IceUtil/FileUtil.h>
using namespace std;
using namespace Ice;
@@ -55,14 +52,13 @@ const IceUtil::Time retryTimeout = IceUtil::Time::seconds(5 * 60);
}
Ice::LoggerI::LoggerI(const string& prefix, const string& file,
- bool convert, const IceUtil::StringConverterPtr& converter,
- size_t sizeMax) :
+ bool convert, size_t sizeMax) :
_prefix(prefix),
_convert(convert),
- _converter(converter),
+ _converter(getProcessStringConverter()),
_sizeMax(sizeMax)
#if defined(_WIN32) && !defined(ICE_OS_WINRT)
- ,_consoleConverter(new IceUtil::WindowsStringConverter(GetConsoleOutputCP()))
+ ,_consoleConverter(createWindowsStringConverter(GetConsoleOutputCP()))
#endif
{
if(!prefix.empty())
@@ -73,7 +69,7 @@ Ice::LoggerI::LoggerI(const string& prefix, const string& file,
if(!file.empty())
{
_file = file;
- _out.open(file, fstream::out | fstream::app);
+ _out.open(IceUtilInternal::streamFilename(file).c_str(), fstream::out | fstream::app);
if(!_out.is_open())
{
throw InitializationException(__FILE__, __LINE__, "FileLogger: cannot open " + _file);
@@ -134,7 +130,8 @@ Ice::LoggerI::getPrefix()
LoggerPtr
Ice::LoggerI::cloneWithPrefix(const std::string& prefix)
{
- return new LoggerI(prefix, _file, _convert, _converter);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(outputMutex); // for _sizeMax
+ return ICE_MAKE_SHARED(LoggerI, prefix, _file, _convert, _sizeMax);
}
void
@@ -202,7 +199,7 @@ Ice::LoggerI::write(const string& message, bool indent)
int err = IceUtilInternal::rename(_file, archive);
- _out.open(_file, fstream::out | fstream::app);
+ _out.open(IceUtilInternal::streamFilename(_file).c_str(), fstream::out | fstream::app);
if(err)
{
@@ -230,15 +227,14 @@ Ice::LoggerI::write(const string& message, bool indent)
error("FileLogger: cannot open `" + _file + "':\nlog messages will be sent to stderr");
write(message, indent);
return;
- }
- }
+ } }
}
_out << s << endl;
}
else
{
#if defined(ICE_OS_WINRT)
- OutputDebugString(IceUtil::stringToWstring(s).c_str());
+ OutputDebugString(stringToWstring(s).c_str());
#elif defined(_WIN32)
//
// Convert the message from the native narrow string encoding to the console
@@ -252,7 +248,7 @@ Ice::LoggerI::write(const string& message, bool indent)
// to Windows console. When _convert is set to false we always output
// UTF-8 encoded messages.
//
- fprintf_s(stderr, "%s\n", IceUtil::nativeToUTF8(s, _converter).c_str());
+ fprintf_s(stderr, "%s\n", nativeToUTF8(s, _converter).c_str());
fflush(stderr);
}
else
@@ -260,7 +256,7 @@ Ice::LoggerI::write(const string& message, bool indent)
try
{
// Convert message to UTF-8
- string u8s = IceUtil::nativeToUTF8(s, _converter);
+ string u8s = nativeToUTF8(s, _converter);
// Then from UTF-8 to console CP
string consoleString;