Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

MJLogger.cc

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------//
00002 //bb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nu//
00003 //                                                                           //
00004 //                         MAJORANA Simulation                               //
00005 //                                                                           //
00006 //      This code implementation is the intellectual property of the         //
00007 //      MAJORANA Collaboration. It is based on Geant4, an intellectual       //
00008 //      property of the RD44 GEANT4 collaboration.                           //
00009 //                                                                           //
00010 //                        *********************                              //
00011 //                                                                           //
00012 //    Neither the authors of this software system, nor their employing       //
00013 //    institutes, nor the agencies providing financial support for this      //
00014 //    work  make  any representation or  warranty, express or implied,       //
00015 //    regarding this software system or assume any liability for its use.    //
00016 //    By copying, distributing or modifying the Program (or any work based   //
00017 //    on on the Program) you indicate your acceptance of this statement,     //
00018 //    and all its terms.                                                     //
00019 //                                                                           //
00020 //bb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nu//
00021 //---------------------------------------------------------------------------//
00022 //                                                          
00023 // $Id: MJLogger.cc,v 1.2 2004/11/09 13:42:39 xliu Exp $ 
00024 //      
00025 // CLASS IMPLEMENTATION:  MJLogger.cc
00026 //
00027 //---------------------------------------------------------------------------//
00033 // 
00034 //---------------------------------------------------------------------------//
00044 //---------------------------------------------------------------------------//
00045 //
00046 
00047 
00048 //---------------------------------------------------------------------------//
00049 
00050 #include "io/MJLogger.hh"      //Present MJ Class Headers 
00051 
00052 //---------------------------------------------------------------------------//
00053 
00054 
00055 //#include <strstream.h>
00056 #include <sstream>
00057 
00058 using namespace std;
00059 
00060 //static ostrstream devnull;
00061 static ostringstream devnull;
00062 
00063 MJLogger::Severity MJLogger::_minSeverity = MJLogger::debugging;
00064 ostream * MJLogger::_myOstream (&cout);
00065 ostream * MJLogger::_myErrstream (&cerr);
00066 ostream * MJLogger::_myNullstream (&devnull);
00067 bool MJLogger::_doPrint = true;
00068 
00069 MJLogger::MJLogger()
00070 {
00071 }
00072 MJLogger::MJLogger(const MJLogger & other)
00073 {
00074 }
00075 
00076 MJLogger::~MJLogger()
00077 {
00078 }
00079 
00080 ostream& 
00081 MJLogger::msg(MJLogger::Severity severity, 
00082                        const char* facility, 
00083                        const char* code )
00084 {
00085   _doPrint = true;
00086   if(severity >= _minSeverity){
00087     *_myOstream << toString(severity) << ":" << facility << ":";
00088   }else{
00089     _doPrint =false;
00090     return *_myNullstream ;
00091   }
00092 
00093   if ( severity == fatal ){
00094     *_myOstream << ::endlog;
00095     ::abort();
00096   }
00097   return *_myOstream;
00098 }
00099 void 
00100 MJLogger::endlog(ostream& os){
00101   if(_doPrint)*_myOstream << endl;
00102 }
00103 char*
00104 MJLogger::toString(MJLogger::Severity sever){
00105   switch (sever) {
00106   case -1:
00107     return "Debug";
00108     break;
00109   case 0:
00110     return "Trace";
00111     break;
00112   case 1:
00113     return "Routine";
00114     break;
00115   case 2:
00116     return "Warning";
00117     break;
00118   case 3:
00119     return "Error";
00120     break;
00121   case 4:
00122     return "Fatal";
00123     break;
00124   }
00125   return "Fatal";
00126 }
00127 
00128 ostream& endlog(ostream& os){
00129   MJLogger::endlog(os);
00130   return devnull;
00131 }

Generated on Mon Nov 29 16:58:52 2004 for Majorana Simulation by  doxygen 1.3.9.1