diff options
author | Antonin Kral <a.kral@bobek.cz> | 2010-09-24 19:01:03 +0200 |
---|---|---|
committer | Antonin Kral <a.kral@bobek.cz> | 2010-09-24 19:01:03 +0200 |
commit | 0ad0c09511a04ebe837f2acb859d47f2aa4e038a (patch) | |
tree | 109babcb556f6c5884b77853120717f0617c7a1e /util/log.h | |
parent | 03e58f81cad8dd4cfcd1530f327116f0cff6ceb3 (diff) | |
download | mongodb-0ad0c09511a04ebe837f2acb859d47f2aa4e038a.tar.gz |
Imported Upstream version 1.6.3
Diffstat (limited to 'util/log.h')
-rw-r--r-- | util/log.h | 77 |
1 files changed, 40 insertions, 37 deletions
@@ -295,10 +295,13 @@ namespace mongo { inline Nullstream& log() { return Logstream::get().prolog(); } + + inline Nullstream& error() { + return log( LL_ERROR ); + } - /* TODOCONCURRENCY */ - inline ostream& stdcout() { - return cout; + inline Nullstream& warning() { + return log( LL_WARNING ); } /* default impl returns "" -- mongod overrides */ @@ -326,40 +329,40 @@ namespace mongo { s << "errno:" << x << ' '; #if defined(_WIN32) - LPTSTR errorText = NULL;
- FormatMessage(
- FORMAT_MESSAGE_FROM_SYSTEM
- |FORMAT_MESSAGE_ALLOCATE_BUFFER
- |FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- x, 0,
- (LPTSTR) &errorText, // output
- 0, // minimum size for output buffer
- NULL);
- if( errorText ) {
- string x = toUtf8String(errorText);
- for( string::iterator i = x.begin(); i != x.end(); i++ ) {
- if( *i == '\n' || *i == '\r' )
- break;
- s << *i;
- }
- LocalFree(errorText);
- }
- else
- s << strerror(x);
- /*
- DWORD n = FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, x,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &lpMsgBuf, 0, NULL);
- */
-#else
- s << strerror(x);
-#endif
- return s.str();
+ LPTSTR errorText = NULL; + FormatMessage( + FORMAT_MESSAGE_FROM_SYSTEM + |FORMAT_MESSAGE_ALLOCATE_BUFFER + |FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + x, 0, + (LPTSTR) &errorText, // output + 0, // minimum size for output buffer + NULL); + if( errorText ) { + string x = toUtf8String(errorText); + for( string::iterator i = x.begin(); i != x.end(); i++ ) { + if( *i == '\n' || *i == '\r' ) + break; + s << *i; + } + LocalFree(errorText); + } + else + s << strerror(x); + /* + DWORD n = FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, x, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR) &lpMsgBuf, 0, NULL); + */ +#else + s << strerror(x); +#endif + return s.str(); } /** output the error # and error message with prefix. |