diff options
Diffstat (limited to 'util/log.h')
-rw-r--r-- | util/log.h | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/util/log.h b/util/log.h index 127282b4c81..b4317dd6b9f 100644 --- a/util/log.h +++ b/util/log.h @@ -133,22 +133,23 @@ namespace mongo { } ss.str(""); } -#define LOGIT { ss << x; return *this; } - Logstream& operator<<(const char *x) LOGIT - Logstream& operator<<(char *x) LOGIT - Logstream& operator<<(char x) LOGIT - Logstream& operator<<(int x) LOGIT - Logstream& operator<<(ExitCode x) LOGIT - Logstream& operator<<(long x) LOGIT - Logstream& operator<<(unsigned long x) LOGIT - Logstream& operator<<(unsigned x) LOGIT - Logstream& operator<<(double x) LOGIT - Logstream& operator<<(void *x) LOGIT - Logstream& operator<<(const void *x) LOGIT - Logstream& operator<<(long long x) LOGIT - Logstream& operator<<(unsigned long long x) LOGIT - Logstream& operator<<(bool x) LOGIT -#undef LOGIT + + /** note these are virtual */ + Logstream& operator<<(const char *x) { ss << x; return *this; } + Logstream& operator<<(char *x) { ss << x; return *this; } + Logstream& operator<<(char x) { ss << x; return *this; } + Logstream& operator<<(int x) { ss << x; return *this; } + Logstream& operator<<(ExitCode x) { ss << x; return *this; } + Logstream& operator<<(long x) { ss << x; return *this; } + Logstream& operator<<(unsigned long x) { ss << x; return *this; } + Logstream& operator<<(unsigned x) { ss << x; return *this; } + Logstream& operator<<(double x) { ss << x; return *this; } + Logstream& operator<<(void *x) { ss << x; return *this; } + Logstream& operator<<(const void *x) { ss << x; return *this; } + Logstream& operator<<(long long x) { ss << x; return *this; } + Logstream& operator<<(unsigned long long x) { ss << x; return *this; } + Logstream& operator<<(bool x) { ss << x; return *this; } + Logstream& operator<<(const LazyString& x) { ss << x.val(); return *this; @@ -243,12 +244,15 @@ namespace mongo { void initLogging( const string& logpath , bool append ); void rotateLogs( int signal = 0 ); -#define MONGO_OUTPUT_ERRNOX(x) "errno:" << x << " " << strerror(x) -#define OUTPUT_ERRNOX MONGO_OUTPUT_ERRNOX - -#define MONGO_OUTPUT_ERRNO OUTPUT_ERRNOX(errno) -#define OUTPUT_ERRNO MONGO_OUTPUT_ERRNO + inline string errnoWithDescription(int x = errno) { + stringstream s; + s << "errno:" << x << ' ' << strerror(x); + return s.str(); + } - string errnostring( const char * prefix = 0 ); + /** output the error # and error message with prefix. + handy for use as parm in uassert/massert. + */ + string errnoWithPrefix( const char * prefix = 0 ); } // namespace mongo |