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
00122
00123
00124
00125
00126 #include <memory>
00127 #include <string>
00128
00129
00130
00131
00132
00133 #include "FWCore/MessageLogger/interface/MessageSender.h"
00134 #include "FWCore/MessageLogger/interface/MessageDrop.h"
00135 #include "FWCore/Utilities/interface/EDMException.h"
00136
00137
00138 namespace edm {
00139
00140 class LogWarning
00141 {
00142 public:
00143 explicit LogWarning( std::string const & id )
00144 : ap ( ELwarning,id,false,(MessageDrop::warningAlwaysSuppressed || !MessageDrop::instance()->warningEnabled))
00145 { }
00146 ~LogWarning();
00147
00148 template< class T >
00149 LogWarning &
00150 operator<< (T const & t) { if(ap.valid()) ap << t; return *this; }
00151 LogWarning &
00152 operator<< ( std::ostream&(*f)(std::ostream&))
00153 { if(ap.valid()) ap << f; return *this; }
00154 LogWarning &
00155 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00156 { if(ap.valid()) ap << f; return *this; }
00157 private:
00158 MessageSender ap;
00159 LogWarning( LogWarning const& );
00160 LogWarning& operator=( LogWarning const& );
00161
00162 };
00163
00164 class LogError
00165 {
00166 public:
00167 explicit LogError( std::string const & id )
00168 : ap ( ELerror,id,false,!MessageDrop::instance()->errorEnabled )
00169 { }
00170 ~LogError();
00171
00172 template< class T >
00173 LogError &
00174 operator<< (T const & t) { if(ap.valid()) ap << t; return *this; }
00175 LogError &
00176 operator<< ( std::ostream&(*f)(std::ostream&))
00177 { if(ap.valid()) ap << f; return *this; }
00178 LogError &
00179 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00180 { if(ap.valid()) ap << f; return *this; }
00181
00182 private:
00183 MessageSender ap;
00184 LogError( LogError const& );
00185 LogError& operator=( LogError const& );
00186
00187 };
00188
00189 class LogSystem
00190 {
00191 public:
00192 explicit LogSystem( std::string const & id )
00193 : ap( ELsevere,id )
00194 { }
00195 ~LogSystem();
00196
00197 template< class T >
00198 LogSystem &
00199 operator<< (T const & t) { ap << t; return *this; }
00200 LogSystem &
00201 operator<< ( std::ostream&(*f)(std::ostream&))
00202 { ap << f; return *this; }
00203 LogSystem &
00204 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00205 { ap << f; return *this; }
00206
00207 private:
00208 MessageSender ap;
00209 LogSystem( LogSystem const& );
00210 LogSystem& operator=( LogSystem const& );
00211
00212 };
00213
00214 class LogInfo
00215 {
00216 public:
00217 explicit LogInfo( std::string const & id )
00218 : ap ( ELinfo,id,false,(MessageDrop::infoAlwaysSuppressed || !MessageDrop::instance()->infoEnabled) )
00219 { }
00220 ~LogInfo();
00221
00222 template< class T >
00223 LogInfo &
00224 operator<< (T const & t) { if(ap.valid()) ap << t; return *this; }
00225 LogInfo &
00226 operator<< ( std::ostream&(*f)(std::ostream&))
00227 { if(ap.valid()) ap << f; return *this; }
00228 LogInfo &
00229 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00230 { if(ap.valid()) ap << f; return *this; }
00231
00232 private:
00233 MessageSender ap;
00234 LogInfo( LogInfo const& );
00235 LogInfo& operator=( LogInfo const& );
00236
00237 };
00238
00239
00240 class LogVerbatim
00241 {
00242 public:
00243 explicit LogVerbatim( std::string const & id )
00244 : ap ( ELinfo,id,true,(MessageDrop::infoAlwaysSuppressed || !MessageDrop::instance()->infoEnabled) )
00245 { }
00246 ~LogVerbatim();
00247
00248 template< class T >
00249 LogVerbatim &
00250 operator<< (T const & t) { if(ap.valid()) ap << t; return *this; }
00251
00252 LogVerbatim &
00253 operator<< ( std::ostream&(*f)(std::ostream&))
00254 { if(ap.valid()) ap << f; return *this; }
00255 LogVerbatim &
00256 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00257 { if(ap.valid()) ap << f; return *this; }
00258
00259 private:
00260 MessageSender ap;
00261 LogVerbatim( LogVerbatim const& );
00262 LogVerbatim& operator=( LogVerbatim const& );
00263
00264 };
00265
00266
00267 class LogPrint
00268 {
00269 public:
00270 explicit LogPrint( std::string const & id )
00271 : ap ( ELwarning,id,true,(MessageDrop::warningAlwaysSuppressed || !MessageDrop::instance()->warningEnabled))
00272 { }
00273 ~LogPrint();
00274
00275 template< class T >
00276 LogPrint &
00277 operator<< (T const & t) { if(ap.valid()) ap << t; return *this; }
00278
00279 LogPrint &
00280 operator<< ( std::ostream&(*f)(std::ostream&))
00281 { if(ap.valid()) ap << f; return *this; }
00282 LogPrint &
00283 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00284 { if(ap.valid()) ap << f; return *this; }
00285
00286 private:
00287 MessageSender ap;
00288 LogPrint( LogPrint const& );
00289 LogPrint& operator=( LogPrint const& );
00290
00291 };
00292
00293
00294
00295 class LogProblem
00296 {
00297 public:
00298 explicit LogProblem ( std::string const & id )
00299 : ap ( ELerror,id,true,!MessageDrop::instance()->errorEnabled )
00300 { }
00301 ~LogProblem();
00302
00303 template< class T >
00304 LogProblem &
00305 operator<< (T const & t) { if(ap.valid()) ap << t; return *this; }
00306 LogProblem &
00307 operator<< ( std::ostream&(*f)(std::ostream&))
00308 { if(ap.valid()) ap << f; return *this; }
00309 LogProblem &
00310 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00311 { if(ap.valid()) ap << f; return *this; }
00312
00313 private:
00314 MessageSender ap;
00315 LogProblem( LogProblem const& );
00316 LogProblem& operator=( LogProblem const& );
00317
00318 };
00319
00320
00321 class LogImportant
00322 {
00323 public:
00324 explicit LogImportant( std::string const & id )
00325 : ap ( ELerror,id,true,!MessageDrop::instance()->errorEnabled )
00326 { }
00327 ~LogImportant();
00328
00329 template< class T >
00330 LogImportant &
00331 operator<< (T const & t) { if(ap.valid()) ap << t; return *this; }
00332 LogImportant &
00333 operator<< ( std::ostream&(*f)(std::ostream&))
00334 { if(ap.valid()) ap << f; return *this; }
00335 LogImportant &
00336 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00337 { if(ap.valid()) ap << f; return *this; }
00338
00339 private:
00340 MessageSender ap;
00341 LogImportant( LogImportant const& );
00342 LogImportant& operator=( LogImportant const& );
00343
00344 };
00345
00346
00347 class LogAbsolute
00348 {
00349 public:
00350 explicit LogAbsolute( std::string const & id )
00351 : ap( ELsevere,id,true )
00352 { }
00353 ~LogAbsolute();
00354
00355 template< class T >
00356 LogAbsolute &
00357 operator<< (T const & t) { ap << t; return *this; }
00358 LogAbsolute &
00359 operator<< ( std::ostream&(*f)(std::ostream&))
00360 { ap << f; return *this; }
00361 LogAbsolute &
00362 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00363 { ap << f; return *this; }
00364
00365 private:
00366 MessageSender ap;
00367 LogAbsolute( LogAbsolute const& );
00368 LogAbsolute& operator=( LogAbsolute const& );
00369
00370 };
00371
00372 std::string stripLeadingDirectoryTree(const std::string & file);
00373
00374
00375
00376 void LogStatistics();
00377
00378 class LogDebug_
00379 {
00380 public:
00381 LogDebug_() : ap() {}
00382 explicit LogDebug_( std::string const & id, std::string const & file, int line );
00383 ~LogDebug_();
00384
00385 template< class T >
00386 LogDebug_ &
00387 operator<< (T const & t)
00388 {
00389 if (ap.valid()) ap << t;
00390 return *this; }
00391 LogDebug_ &
00392 operator<< ( std::ostream&(*f)(std::ostream&))
00393 {
00394 if (ap.valid()) ap << f;
00395 return *this; }
00396 LogDebug_ &
00397 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00398 {
00399 if (ap.valid()) ap << f;
00400 return *this; }
00401
00402
00403 private:
00404 MessageSender ap;
00405 std::string stripLeadingDirectoryTree (const std::string & file) const;
00406
00407 };
00408
00409 class LogTrace_
00410 {
00411 public:
00412 LogTrace_() : ap() {}
00413 explicit LogTrace_( std::string const & id );
00414 ~LogTrace_();
00415
00416 template< class T >
00417 LogTrace_ &
00418 operator<< (T const & t)
00419 {
00420 if (ap.valid()) ap << t;
00421 return *this; }
00422 LogTrace_ &
00423 operator<< ( std::ostream&(*f)(std::ostream&))
00424 {
00425 if (ap.valid()) ap << f;
00426 return *this; }
00427 LogTrace_ &
00428 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00429 {
00430 if (ap.valid()) ap << f;
00431 return *this; }
00432
00433
00434 private:
00435 MessageSender ap;
00436
00437 };
00438
00439
00440 namespace edmmltest {
00441 class LogWarningThatSuppressesLikeLogInfo
00442 {
00443 public:
00444 explicit LogWarningThatSuppressesLikeLogInfo( std::string const & id )
00445 : ap ( ELwarning,id,false,(MessageDrop::infoAlwaysSuppressed || !MessageDrop::instance()->warningEnabled) )
00446 { }
00447 ~LogWarningThatSuppressesLikeLogInfo();
00448 template< class T >
00449 LogWarningThatSuppressesLikeLogInfo &
00450 operator<< (T const & t) { if(ap.valid()) ap << t; return *this; }
00451 LogWarningThatSuppressesLikeLogInfo &
00452 operator<< ( std::ostream&(*f)(std::ostream&))
00453 { if(ap.valid()) ap << f; return *this; }
00454 LogWarningThatSuppressesLikeLogInfo &
00455 operator<< ( std::ios_base&(*f)(std::ios_base&) )
00456 { if(ap.valid()) ap << f; return *this; }
00457 private:
00458 MessageSender ap;
00459 LogWarningThatSuppressesLikeLogInfo( LogWarningThatSuppressesLikeLogInfo const& );
00460 LogWarningThatSuppressesLikeLogInfo& operator=( LogWarningThatSuppressesLikeLogInfo const& );
00461
00462 };
00463 }
00464
00465 class Suppress_LogDebug_
00466 {
00467
00468
00469
00470 public:
00471 template< class T >
00472 Suppress_LogDebug_ &operator<< (T const&) { return *this; }
00473 Suppress_LogDebug_ &operator<< (std::ostream&(*)(std::ostream&)) { return *this; }
00474 Suppress_LogDebug_ &operator<< (std::ios_base&(*)(std::ios_base&)) { return *this; }
00475 };
00476
00477 bool isDebugEnabled();
00478 bool isInfoEnabled();
00479 bool isWarningEnabled();
00480 void HaltMessageLogging();
00481 void FlushMessageLog();
00482 void snapshotMessageLog();
00483 void GroupLogStatistics(std::string const & category);
00484 bool isMessageProcessingSetUp();
00485
00486
00487
00488
00489 void setStandAloneMessageThreshold (std::string const & severity);
00490 void squelchStandAloneMessageCategory (std::string const & category);
00491
00492 }
00493
00494
00495
00496
00497
00498
00499
00500 #ifndef EDM_ML_DEBUG
00501 #define LogDebug(id) true ? edm::Suppress_LogDebug_() : edm::Suppress_LogDebug_()
00502 #define LogTrace(id) true ? edm::Suppress_LogDebug_() : edm::Suppress_LogDebug_()
00503 #else
00504
00505 #define LogDebug(id) (edm::MessageDrop::debugAlwaysSuppressed || !edm::MessageDrop::debugEnabled) ? edm::LogDebug_() : edm::LogDebug_(id, __FILE__, __LINE__)
00506 #define LogTrace(id) (edm::MessageDrop::debugAlwaysSuppressed || !edm::MessageDrop::debugEnabled) ? edm::LogTrace_() : edm::LogTrace_(id)
00507 #endif
00508
00509 #endif // MessageLogger_MessageLogger_h
00510