[yast-commit] r55811 - in /trunk/storage/libstorage/src: AppUtil.cc AppUtil.h
Author: aschnell Date: Fri Feb 27 12:28:54 2009 New Revision: 55811 URL: http://svn.opensuse.org/viewcvs/yast?rev=55811&view=rev Log: - reduced size of generated code for logging functions Modified: trunk/storage/libstorage/src/AppUtil.cc trunk/storage/libstorage/src/AppUtil.h Modified: trunk/storage/libstorage/src/AppUtil.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/AppUtil.cc... ============================================================================== --- trunk/storage/libstorage/src/AppUtil.cc (original) +++ trunk/storage/libstorage/src/AppUtil.cc Fri Feb 27 12:28:54 2009 @@ -360,18 +360,22 @@ } -void -prepareLogStream(std::ostringstream& s) +ostringstream* +logStreamOpen() { - s.imbue(std::locale::classic()); - s.setf(std::ios::boolalpha); - s.setf(std::ios::showbase); + std::ostringstream* stream = new ostringstream; + + stream->imbue(std::locale::classic()); + stream->setf(std::ios::boolalpha); + stream->setf(std::ios::showbase); + + return stream; } void -logMsg(LogLevel level, const char* file, unsigned line, const char* func, - const string& str) +logStreamClose(LogLevel level, const char* file, unsigned line, const char* func, + ostringstream* stream) { using namespace blocxx; @@ -405,9 +409,11 @@ if (!category.empty()) { LogAppender::getCurrentLogAppender()->logMessage(LogMessage(component, category, - String(str), file, - line, func)); + String(stream->str()), + file, line, func)); } + + delete stream; } Modified: trunk/storage/libstorage/src/AppUtil.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/AppUtil.h?... ============================================================================== --- trunk/storage/libstorage/src/AppUtil.h (original) +++ trunk/storage/libstorage/src/AppUtil.h Fri Feb 27 12:28:54 2009 @@ -32,7 +32,7 @@ bool multipleDelim=true, bool skipEmpty=true, const string& quotes="" ); string mergeString( const std::list<string>& l, const string& del=" " ); -std::map<string,string> makeMap( const std::list<string>& l, +std::map<string,string> makeMap( const std::list<string>& l, const string& delim = "=", const string& removeSur = " \t\n" ); @@ -61,24 +61,23 @@ bool testLogLevel(LogLevel level); -void logMsg(LogLevel level, const char* file, unsigned line, - const char* func, const string& str); +std::ostringstream* logStreamOpen(); + +void logStreamClose(LogLevel level, const char* file, unsigned line, + const char* func, std::ostringstream*); -void prepareLogStream(std::ostringstream& s); - #define y2deb(op) y2log_op(storage::DEBUG, __FILE__, __LINE__, __FUNCTION__, op) #define y2mil(op) y2log_op(storage::MILESTONE, __FILE__, __LINE__, __FUNCTION__, op) #define y2war(op) y2log_op(storage::WARNING, __FILE__, __LINE__, __FUNCTION__, op) #define y2err(op) y2log_op(storage::ERROR, __FILE__, __LINE__, __FUNCTION__, op) -#define y2log_op(level, file, line, function, op) \ +#define y2log_op(level, file, line, func, op) \ do { \ if (storage::testLogLevel(level)) \ { \ - std::ostringstream __buf; \ - storage::prepareLogStream(__buf); \ - __buf << op; \ - storage::logMsg(level, file, line, function, __buf.str()); \ + std::ostringstream* __buf = storage::logStreamOpen(); \ + *__buf << op; \ + storage::logStreamClose(level, file, line, func, __buf); \ } \ } while (0) -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
aschnell@svn.opensuse.org