diff options
author | dwight <dwight@10gen.com> | 2009-09-03 14:58:05 -0400 |
---|---|---|
committer | dwight <dwight@10gen.com> | 2009-09-03 14:58:05 -0400 |
commit | 93f07dbc7dd0780966a8f9057274b22637e99bbd (patch) | |
tree | a12262fa663846ad5053e39c690201d1b68ca5c0 /util/log.h | |
parent | 2470913c7012b3d14a013a88bee3ee405705bf59 (diff) | |
download | mongo-93f07dbc7dd0780966a8f9057274b22637e99bbd.tar.gz |
interim ocmmit of new logging stuff
Diffstat (limited to 'util/log.h')
-rw-r--r-- | util/log.h | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/util/log.h b/util/log.h index 1d0dec3adda..77a9ce8e6de 100644 --- a/util/log.h +++ b/util/log.h @@ -38,7 +38,7 @@ namespace mongo { private: const T& t_; }; - + class Nullstream { public: virtual ~Nullstream() {} @@ -169,39 +169,47 @@ namespace mongo { cout << curNs << ' '; return *this; } + private: + static thread_specific_ptr<Logstream> tsp; + public: + static Logstream& get() { + Logstream *p = tsp.get(); + if( p == 0 ) + tsp.reset( p = new Logstream() ); + return *p; + } }; - extern Logstream logstream; extern int logLevel; inline Nullstream& problem( int level = 0 ) { if ( level > logLevel ) return nullstream; - return logstream.prolog(true); + return Logstream::get().prolog(true); } inline Nullstream& out( int level = 0 ) { if ( level > logLevel ) return nullstream; - return logstream; + return Logstream::get(); } /* flush the log stream if the log level is at the specified level or higher. */ inline void logflush(int level = 0) { if( level > logLevel ) - logstream.flush(); + Logstream::get().flush(); } inline Nullstream& log( int level = 0 ){ if ( level > logLevel ) return nullstream; - return logstream.prolog(); + return Logstream::get().prolog(); } + /* TODOCONCURRENCY */ inline ostream& stdcout() { return cout; } - } // namespace mongo |