summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2016-04-12 10:48:01 +0200
committerBenoit Foucher <benoit@zeroc.com>2016-04-12 10:48:01 +0200
commit48525e3c4ee4f232de620ac37d761f836bd4289f (patch)
treed8fdfc7aad9d4589cba37644a3ca4f87fe9de820 /cpp
parentPHP test fix to build with 3.6.2 binary distribution (diff)
downloadice-48525e3c4ee4f232de620ac37d761f836bd4289f.tar.bz2
ice-48525e3c4ee4f232de620ac37d761f836bd4289f.tar.xz
ice-48525e3c4ee4f232de620ac37d761f836bd4289f.zip
Minor style fixes to log file archiving change
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Ice/LoggerI.cpp25
-rw-r--r--cpp/src/Ice/LoggerI.h4
-rwxr-xr-xcpp/test/Ice/logger/run.py2
3 files changed, 15 insertions, 16 deletions
diff --git a/cpp/src/Ice/LoggerI.cpp b/cpp/src/Ice/LoggerI.cpp
index 6ce48d0338c..0904b8d3dd9 100644
--- a/cpp/src/Ice/LoggerI.cpp
+++ b/cpp/src/Ice/LoggerI.cpp
@@ -50,7 +50,8 @@ Init init;
// Timeout in milliseconds after which rename will be attempted
// in case of failures renaming files. That is set to 5 minutes.
//
-const Ice::Long retryTimeout = 5 * 60 * 1000;
+const IceUtil::Time retryTimeout = IceUtil::Time::seconds(5 * 60);
+
}
Ice::LoggerI::LoggerI(const string& prefix, const string& file,
@@ -62,8 +63,7 @@ Ice::LoggerI::LoggerI(const string& prefix, const string& file,
#if defined(_WIN32) && !defined(ICE_OS_WINRT)
_consoleConverter(new IceUtil::WindowsStringConverter(GetConsoleOutputCP())),
#endif
- _sizeMax(sizeMax),
- _nextRetry(0)
+ _sizeMax(sizeMax)
{
if(!prefix.empty())
{
@@ -159,14 +159,12 @@ Ice::LoggerI::write(const string& message, bool indent)
if(_sizeMax > 0)
{
//
- // If file size + message size exceed max size we archive the log file,
+ // If file size + message size exceeds max size we archive the log file,
// but we do not archive empty files or truncate messages.
//
size_t sz = static_cast<size_t>(_out.tellp());
- if(sz > 0 && sz + message.size() >= _sizeMax &&
- (_nextRetry == 0 || _nextRetry <= IceUtil::Time::now().toMilliSeconds()))
+ if(sz > 0 && sz + message.size() >= _sizeMax && _nextRetry <= IceUtil::Time::now())
{
-
string basename = _file;
string ext;
@@ -208,27 +206,28 @@ Ice::LoggerI::write(const string& message, bool indent)
if(err)
{
- _nextRetry = retryTimeout + IceUtil::Time::now().toMilliSeconds();
+ _nextRetry = IceUtil::Time::now() + retryTimeout;
+
//
- // We temporally set the maximum size to 0 to ensure that there isn't any rename attempts
+ // We temporarily set the maximum size to 0 to ensure there isn't more rename attempts
// in the nested error call.
//
size_t sizeMax = _sizeMax;
_sizeMax = 0;
sync.release();
- error("FileLogger: cannot rename " + _file + "\n" + IceUtilInternal::lastErrorToString());
+ error("FileLogger: cannot rename `" + _file + "'\n" + IceUtilInternal::lastErrorToString());
sync.acquire();
_sizeMax = sizeMax;
}
- else if(_nextRetry != 0)
+ else
{
- _nextRetry = 0;
+ _nextRetry = IceUtil::Time();
}
if(!_out.is_open())
{
sync.release();
- error("FileLogger: cannot open " + _file + " log messages will be send to stderr");
+ error("FileLogger: cannot open `" + _file + "':\nlog messages will be sent to stderr");
write(message, indent);
return;
}
diff --git a/cpp/src/Ice/LoggerI.h b/cpp/src/Ice/LoggerI.h
index f6d8573df84..1c516bad393 100644
--- a/cpp/src/Ice/LoggerI.h
+++ b/cpp/src/Ice/LoggerI.h
@@ -44,12 +44,12 @@ private:
std::string _file;
std::size_t _sizeMax;
-
+
//
// In case of a log file rename failure is set to the time in milliseconds
// after which rename could be attempted again. Otherwise is set to zero.
//
- Ice::Long _nextRetry;
+ IceUtil::Time _nextRetry;
#if defined(_WIN32) && !defined(ICE_OS_WINRT)
const IceUtil::StringConverterPtr _consoleConverter;
#endif
diff --git a/cpp/test/Ice/logger/run.py b/cpp/test/Ice/logger/run.py
index 5d49ec1185a..23dadf58de2 100755
--- a/cpp/test/Ice/logger/run.py
+++ b/cpp/test/Ice/logger/run.py
@@ -135,7 +135,7 @@ if (not os.path.isfile("log/client5-4.log") or
sys.exit(1)
with open("log/client5-4.log", 'r') as f:
- if f.read().count("error: FileLogger: cannot rename log/client5-4.log") != 1:
+ if f.read().count("error: FileLogger: cannot rename `log/client5-4.log'") != 1:
print("failed!")
sys.exit(1)