diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/LoggerI.cpp | 25 | ||||
-rw-r--r-- | cpp/src/Ice/LoggerI.h | 4 | ||||
-rw-r--r-- | cpp/src/Slice/PythonUtil.cpp | 32 |
3 files changed, 22 insertions, 39 deletions
diff --git a/cpp/src/Ice/LoggerI.cpp b/cpp/src/Ice/LoggerI.cpp index 8b89e80b908..9aa0d10b7ce 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 b91a00a93a1..c48e768d1b4 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/src/Slice/PythonUtil.cpp b/cpp/src/Slice/PythonUtil.cpp index d471f3448e5..699bd08ef97 100644 --- a/cpp/src/Slice/PythonUtil.cpp +++ b/cpp/src/Slice/PythonUtil.cpp @@ -2294,14 +2294,10 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const string& for(StringVec::const_iterator q = lines.begin(); q != lines.end(); ++q) { - if(q != lines.begin()) - { - _out << nl; - } - _out << *q; + _out << nl << *q; } - _out << "\"\"\""; + _out << nl << "\"\"\""; } void @@ -2317,11 +2313,7 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const DataMemb for(StringVec::const_iterator q = lines.begin(); q != lines.end(); ++q) { - if(q != lines.begin()) - { - _out << nl; - } - _out << *q; + _out << nl << *q; } if(!members.empty()) @@ -2363,7 +2355,7 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const DataMemb } } - _out << "\"\"\""; + _out << nl << "\"\"\""; } void @@ -2379,11 +2371,7 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const Enumerat for(StringVec::const_iterator q = lines.begin(); q != lines.end(); ++q) { - if(q != lines.begin()) - { - _out << nl; - } - _out << *q; + _out << nl << *q; } if(!enums.empty()) @@ -2425,7 +2413,7 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const Enumerat } } - _out << "\"\"\""; + _out << nl << "\"\"\""; } bool @@ -2668,11 +2656,7 @@ Slice::Python::CodeVisitor::writeDocstring(const OperationPtr& op, DocstringMode { for(StringVec::const_iterator q = comment.description.begin(); q != comment.description.end(); ++q) { - if(q != comment.description.begin()) - { - _out << nl; - } - _out << *q; + _out << nl << *q; } } @@ -2801,7 +2785,7 @@ Slice::Python::CodeVisitor::writeDocstring(const OperationPtr& op, DocstringMode _out << nl << r->first << " -- " << r->second; } } - _out << "\"\"\""; + _out << nl << "\"\"\""; } void |