Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:02

0001 #ifndef Fireworks_Core_fwLog_h
0002 #define Fireworks_Core_fwLog_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Core
0006 // Class  :     fwLog
0007 //
0008 /**\class fwLog fwLog.h Fireworks/Core/interface/fwLog.h
0009 
0010  Description: Simple logging utility
0011 
0012  Usage:
0013     To send a message to the logger
0014        fwLog(kDebug) << "This is my message"<<std::endl;
0015  
0016     To change the message levels which will be recorded
0017        fwlog::setPresentLevel(kDebug);
0018  
0019     To change where the messages go, just pass the address of an instance of std::ostream
0020        fwlog::setLogger(&std::cerr);
0021 
0022 */
0023 //
0024 // Original Author:  Chris Jones
0025 //         Created:  Tue Dec  8 23:10:04 CST 2009
0026 //
0027 
0028 // system include files
0029 #include <iostream>
0030 
0031 // user include files
0032 
0033 // forward declarations
0034 namespace fwlog {
0035   enum LogLevel { kDebug, kInfo, kWarning, kError };
0036 
0037   const char* levelName(LogLevel);
0038   std::ostream& logger();
0039   void setLogger(std::ostream*);
0040 
0041   LogLevel presentLogLevel();
0042   void setPresentLogLevel(LogLevel);
0043 }  // namespace fwlog
0044 
0045 #define fwLog(_level_) \
0046   (fwlog::presentLogLevel() > _level_) ? fwlog::logger() : fwlog::logger() << fwlog::levelName(_level_) << ": "
0047 
0048 #endif