summaryrefslogtreecommitdiff
path: root/util/log.h
diff options
context:
space:
mode:
authorDwight Merriman <dwight@10gen.com>2010-04-24 14:03:14 -0400
committerDwight Merriman <dwight@10gen.com>2010-04-24 14:03:14 -0400
commit0c7e5438e069650fdc13a75f64b492c4d4eb3e41 (patch)
treef10a3182dcbe27255caf220712c461a1dd12e744 /util/log.h
parent0c7aa5f86140af68d79ff002453eaa7930675e6c (diff)
downloadmongo-0c7e5438e069650fdc13a75f64b492c4d4eb3e41.tar.gz
get rid of macros in log.h
Diffstat (limited to 'util/log.h')
-rw-r--r--util/log.h48
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