Go to the documentation of this file.00001 #ifndef MessageLogger_MessageLogger_h
00002 #define MessageLogger_MessageLogger_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 #include <memory>
00122 #include <string>
00123
00124
00125
00126
00127
00128 #include "FWCore/MessageLogger/interface/MessageSender.h"
00129 #include "FWCore/MessageLogger/interface/MessageDrop.h"
00130 #include "FWCore/Utilities/interface/EDMException.h"
00131
00132
00133 namespace edm {
00134
00135 class LogWarning
00136 {
00137 public:
00138 explicit LogWarning( std::string const & id )
00139 : ap ( (!MessageDrop::warningAlwaysSuppressed
00140 && edm::MessageDrop::instance()->warningEnabled) ?
00141 new MessageSender(ELwarning,id) : 0 )
00142 { }
00143 ~LogWarning();
00144
00145 template< class T >
00146 LogWarning &
00147 operator<< (T const & t) { if(ap.get()) (*ap) << t; return *this; }
00148 LogWarning &
00149 operator<< ( std::ostream&(*f)(std::ostream&))
00150 { if(ap.get()) (*ap) << f; return *this; }
00151 LogWarning &
00152 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00153 { if(ap.get()) (*ap) << f; return *this; }
00154 private:
00155 std::auto_ptr<MessageSender> ap;
00156 LogWarning( LogWarning const& );
00157
00158 };
00159
00160 class LogError
00161 {
00162 public:
00163 explicit LogError( std::string const & id )
00164 : ap ( (edm::MessageDrop::instance()->errorEnabled) ?
00165 new MessageSender(ELerror,id) : 0 )
00166 { }
00167 ~LogError();
00168
00169 template< class T >
00170 LogError &
00171 operator<< (T const & t) { (*ap) << t; return *this; }
00172 LogError &
00173 operator<< ( std::ostream&(*f)(std::ostream&))
00174 { (*ap) << f; return *this; }
00175 LogError &
00176 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00177 { (*ap) << f; return *this; }
00178
00179 private:
00180 std::auto_ptr<MessageSender> ap;
00181 LogError( LogError const& );
00182
00183 };
00184
00185 class LogSystem
00186 {
00187 public:
00188 explicit LogSystem( std::string const & id )
00189 : ap( new MessageSender(ELsevere,id) )
00190 { }
00191 ~LogSystem();
00192
00193 template< class T >
00194 LogSystem &
00195 operator<< (T const & t) { (*ap) << t; return *this; }
00196 LogSystem &
00197 operator<< ( std::ostream&(*f)(std::ostream&))
00198 { (*ap) << f; return *this; }
00199 LogSystem &
00200 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00201 { (*ap) << f; return *this; }
00202
00203 private:
00204 std::auto_ptr<MessageSender> ap;
00205 LogSystem( LogSystem const& );
00206
00207 };
00208
00209 class LogInfo
00210 {
00211 public:
00212 explicit LogInfo( std::string const & id )
00213 : ap ( (!MessageDrop::infoAlwaysSuppressed
00214 && edm::MessageDrop::instance()->infoEnabled) ?
00215 new MessageSender(ELinfo,id) : 0 )
00216 { }
00217 ~LogInfo();
00218
00219 template< class T >
00220 LogInfo &
00221 operator<< (T const & t) { if(ap.get()) (*ap) << t; return *this; }
00222 LogInfo &
00223 operator<< ( std::ostream&(*f)(std::ostream&))
00224 { if(ap.get()) (*ap) << f; return *this; }
00225 LogInfo &
00226 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00227 { if(ap.get()) (*ap) << f; return *this; }
00228
00229 private:
00230 std::auto_ptr<MessageSender> ap;
00231 LogInfo( LogInfo const& );
00232
00233 };
00234
00235
00236 class LogVerbatim
00237 {
00238 public:
00239 explicit LogVerbatim( std::string const & id )
00240 : ap ( (!MessageDrop::infoAlwaysSuppressed
00241 && edm::MessageDrop::instance()->infoEnabled) ?
00242 new MessageSender(ELinfo,id,true) : 0 )
00243 { }
00244 ~LogVerbatim();
00245
00246 template< class T >
00247 LogVerbatim &
00248 operator<< (T const & t) { if(ap.get()) (*ap) << t; return *this; }
00249
00250 LogVerbatim &
00251 operator<< ( std::ostream&(*f)(std::ostream&))
00252 { if(ap.get()) (*ap) << f; return *this; }
00253 LogVerbatim &
00254 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00255 { if(ap.get()) (*ap) << f; return *this; }
00256
00257 private:
00258 std::auto_ptr<MessageSender> ap;
00259 LogVerbatim( LogVerbatim const& );
00260
00261 };
00262
00263
00264 class LogPrint
00265 {
00266 public:
00267 explicit LogPrint( std::string const & id )
00268 : ap ( (!MessageDrop::warningAlwaysSuppressed
00269 && edm::MessageDrop::instance()->warningEnabled) ?
00270 new MessageSender(ELwarning,id,true) : 0 )
00271 { }
00272 ~LogPrint();
00273
00274 template< class T >
00275 LogPrint &
00276 operator<< (T const & t) { if(ap.get()) (*ap) << t; return *this; }
00277
00278 LogPrint &
00279 operator<< ( std::ostream&(*f)(std::ostream&))
00280 { if(ap.get()) (*ap) << f; return *this; }
00281 LogPrint &
00282 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00283 { if(ap.get()) (*ap) << f; return *this; }
00284
00285 private:
00286 std::auto_ptr<MessageSender> ap;
00287 LogPrint( LogPrint const& );
00288
00289 };
00290
00291
00292
00293 class LogProblem
00294 {
00295 public:
00296 explicit LogProblem ( std::string const & id )
00297 : ap ( (edm::MessageDrop::instance()->errorEnabled) ?
00298 new MessageSender(ELerror,id,true) : 0 )
00299 { }
00300 ~LogProblem();
00301
00302 template< class T >
00303 LogProblem &
00304 operator<< (T const & t) { (*ap) << t; return *this; }
00305 LogProblem &
00306 operator<< ( std::ostream&(*f)(std::ostream&))
00307 { (*ap) << f; return *this; }
00308 LogProblem &
00309 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00310 { (*ap) << f; return *this; }
00311
00312 private:
00313 std::auto_ptr<MessageSender> ap;
00314 LogProblem( LogProblem const& );
00315
00316 };
00317
00318
00319 class LogImportant
00320 {
00321 public:
00322 explicit LogImportant( std::string const & id )
00323 : ap ( (edm::MessageDrop::instance()->errorEnabled) ?
00324 new MessageSender(ELerror,id,true) : 0 )
00325 { }
00326 ~LogImportant();
00327
00328 template< class T >
00329 LogImportant &
00330 operator<< (T const & t) { (*ap) << t; return *this; }
00331 LogImportant &
00332 operator<< ( std::ostream&(*f)(std::ostream&))
00333 { (*ap) << f; return *this; }
00334 LogImportant &
00335 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00336 { (*ap) << f; return *this; }
00337
00338 private:
00339 std::auto_ptr<MessageSender> ap;
00340 LogImportant( LogImportant const& );
00341
00342 };
00343
00344
00345 class LogAbsolute
00346 {
00347 public:
00348 explicit LogAbsolute( std::string const & id )
00349 : ap( new MessageSender(ELsevere,id,true) )
00350 { }
00351 ~LogAbsolute();
00352
00353 template< class T >
00354 LogAbsolute &
00355 operator<< (T const & t) { (*ap) << t; return *this; }
00356 LogAbsolute &
00357 operator<< ( std::ostream&(*f)(std::ostream&))
00358 { (*ap) << f; return *this; }
00359 LogAbsolute &
00360 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00361 { (*ap) << f; return *this; }
00362
00363 private:
00364 std::auto_ptr<MessageSender> ap;
00365 LogAbsolute( LogAbsolute const& );
00366
00367 };
00368
00369 std::string stripLeadingDirectoryTree(const std::string & file);
00370
00371
00372
00373 void LogStatistics();
00374
00375 class LogDebug_
00376 {
00377 public:
00378 explicit LogDebug_( std::string const & id, std::string const & file, int line );
00379 explicit LogDebug_() : ap(), debugEnabled(false) {}
00380 ~LogDebug_();
00381
00382 template< class T >
00383 LogDebug_ &
00384 operator<< (T const & t)
00385 { if (!debugEnabled) return *this;
00386 if (ap.get()) (*ap) << t;
00387 else Exception::throwThis
00388 (edm::errors::LogicError,"operator << to stale copied LogDebug_ object");
00389 return *this; }
00390 LogDebug_ &
00391 operator<< ( std::ostream&(*f)(std::ostream&))
00392 { if (!debugEnabled) return *this;
00393 if (ap.get()) (*ap) << f;
00394 else Exception::throwThis
00395 (edm::errors::LogicError,"operator << to stale copied LogDebug_ object");
00396 return *this; }
00397 LogDebug_ &
00398 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00399 { if (!debugEnabled) return *this;
00400 if (ap.get()) (*ap) << f;
00401 else Exception::throwThis
00402 (edm::errors::LogicError,"operator << to stale copied LogDebug_ object");
00403 return *this; }
00404
00405
00406 private:
00407 std::auto_ptr<MessageSender> ap;
00408 bool debugEnabled;
00409 std::string stripLeadingDirectoryTree (const std::string & file) const;
00410
00411 };
00412
00413 class LogTrace_
00414 {
00415 public:
00416 explicit LogTrace_( std::string const & id );
00417 explicit LogTrace_() : ap(), debugEnabled(false) {}
00418 ~LogTrace_();
00419
00420 template< class T >
00421 LogTrace_ &
00422 operator<< (T const & t)
00423 { if (!debugEnabled) return *this;
00424 if (ap.get()) (*ap) << t;
00425 else Exception::throwThis
00426 (edm::errors::LogicError,"operator << to stale copied LogTrace_ object");
00427 return *this; }
00428 LogTrace_ &
00429 operator<< ( std::ostream&(*f)(std::ostream&))
00430 { if (!debugEnabled) return *this;
00431 if (ap.get()) (*ap) << f;
00432 else Exception::throwThis
00433 (edm::errors::LogicError,"operator << to stale copied LogTrace_ object");
00434 return *this; }
00435 LogTrace_ &
00436 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00437 { if (!debugEnabled) return *this;
00438 if (ap.get()) (*ap) << f;
00439 else Exception::throwThis
00440 (edm::errors::LogicError,"operator << to stale copied LogTrace_ object");
00441 return *this; }
00442
00443
00444 private:
00445 std::auto_ptr<MessageSender> ap;
00446 bool debugEnabled;
00447
00448 };
00449
00450
00451 namespace edmmltest {
00452 class LogWarningThatSuppressesLikeLogInfo
00453 {
00454 public:
00455 explicit LogWarningThatSuppressesLikeLogInfo( std::string const & id )
00456 : ap ( (!MessageDrop::infoAlwaysSuppressed
00457 && edm::MessageDrop::instance()->warningEnabled) ?
00458 new MessageSender(ELwarning,id) : 0 )
00459 { }
00460 ~LogWarningThatSuppressesLikeLogInfo();
00461 template< class T >
00462 LogWarningThatSuppressesLikeLogInfo &
00463 operator<< (T const & t) { if(ap.get()) (*ap) << t; return *this; }
00464 LogWarningThatSuppressesLikeLogInfo &
00465 operator<< ( std::ostream&(*f)(std::ostream&))
00466 { if(ap.get()) (*ap) << f; return *this; }
00467 LogWarningThatSuppressesLikeLogInfo &
00468 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00469 { if(ap.get()) (*ap) << f; return *this; }
00470 private:
00471 std::auto_ptr<MessageSender> ap;
00472 LogWarningThatSuppressesLikeLogInfo( LogWarningThatSuppressesLikeLogInfo const& );
00473
00474 };
00475 }
00476
00477 extern LogDebug_ dummyLogDebugObject_;
00478 extern LogTrace_ dummyLogTraceObject_;
00479
00480 class Suppress_LogDebug_
00481 {
00482
00483
00484
00485 public:
00486 template< class T >
00487 Suppress_LogDebug_ &operator<< (T const&) { return *this; }
00488 Suppress_LogDebug_ &operator<< (std::ostream&(*)(std::ostream&)) { return *this; }
00489 Suppress_LogDebug_ &operator<< (std::ios_base&(*)(std::ios_base&)) { return *this; }
00490 };
00491
00492 bool isDebugEnabled();
00493 bool isInfoEnabled();
00494 bool isWarningEnabled();
00495 void HaltMessageLogging();
00496 void FlushMessageLog();
00497 void snapshotMessageLog();
00498 void GroupLogStatistics(std::string const & category);
00499 bool isMessageProcessingSetUp();
00500
00501
00502
00503
00504 void setStandAloneMessageThreshold (std::string const & severity);
00505 void squelchStandAloneMessageCategory (std::string const & category);
00506
00507 }
00508
00509
00510
00511
00512
00513
00514
00515 #ifndef EDM_ML_DEBUG
00516 #define LogDebug(id) true ? edm::Suppress_LogDebug_() : edm::Suppress_LogDebug_()
00517 #define LogTrace(id) true ? edm::Suppress_LogDebug_() : edm::Suppress_LogDebug_()
00518 #else
00519
00520 #define LogDebug(id) (edm::MessageDrop::debugAlwaysSuppressed || !edm::MessageDrop::debugEnabled) ? edm::LogDebug_() : edm::LogDebug_(id, __FILE__, __LINE__)
00521 #define LogTrace(id) (edm::MessageDrop::debugAlwaysSuppressed || !edm::MessageDrop::debugEnabled) ? edm::LogTrace_() : edm::LogTrace_(id)
00522 #endif
00523
00524 #endif // MessageLogger_MessageLogger_h
00525