CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | Friends

edm::ELlog4cplus Class Reference

#include <ELlog4cplus.h>

Inheritance diagram for edm::ELlog4cplus:
edm::service::ELdestination evf::RunBase

List of all members.

Public Member Functions

virtual ELlog4cplusclone () const
 ELlog4cplus ()
 ELlog4cplus (const ELlog4cplus &orig)
virtual bool log (const ErrorObj &msg)
void setAppl (xdaq::Application *a)
void xxxxSet (int i)
void xxxxShout ()
virtual ~ELlog4cplus ()

Protected Member Functions

virtual void attachEpilogue ()
virtual void attachTime ()
virtual void emit (const ELstring &s, bool nl=false)
virtual void includeContext ()
virtual void includeModule ()
virtual void includeSerial ()
virtual void includeSubroutine ()
virtual void includeText ()
virtual void includeTime ()
ELlog4cplusoperator= (const ELlog4cplus &orig)
virtual void separateEpilogue ()
virtual void separateTime ()
virtual void summarization (const ELstring &fullTitle, const ELstring &sumLines)
virtual void suppressContext ()
virtual void suppressModule ()
virtual void suppressSerial ()
virtual void suppressSubroutine ()
virtual void suppressText ()
virtual void suppressTime ()
virtual void useContext ()
virtual void useFullContext ()

Protected Attributes

int charsOnLine
std::ostringstream * os
std::ostringstream os_
bool osIsOwned
bool wantEpilogueSeparate
bool wantFullContext
bool wantModule
bool wantSerial
bool wantSomeContext
bool wantSubroutine
bool wantText
bool wantTimeSeparate
bool wantTimestamp
ELextendedID xid
int xxxxInt

Private Attributes

xdaq::Application * appl_

Friends

class service::ELdestControl

Detailed Description

Definition at line 51 of file ELlog4cplus.h.


Constructor & Destructor Documentation

edm::ELlog4cplus::ELlog4cplus ( )

Definition at line 84 of file ELlog4cplus.cc.

References dtNoiseDBValidation_cfg::cerr, emit(), edm::formatTime(), edm::service::ELdestination::lineLength, and cond::rpcobgas::time.

Referenced by clone().

: ELdestination       (            )
, os                  ( &os_ )
, osIsOwned           ( false      )
, charsOnLine         ( 0          )
, xid                 (            )
, wantTimestamp       ( true       )
, wantModule          ( true       )
, wantSubroutine      ( true       )
, wantText            ( true       )
, wantSomeContext     ( true       )
, wantSerial          ( false      )
, wantFullContext     ( false      )
, wantTimeSeparate    ( false      )
, wantEpilogueSeparate( false      )
, xxxxInt             ( 0          )
, appl_               ( 0          )
{
  //  makeFileAppender(); // this is not needed/wanted. An appender must be provided by the application itself

  #ifdef ELlog4cplusCONSTRUCTOR_TRACE
    std::cerr << "Constructor for ELlog4cplus()\n";
  #endif

  lineLength = 32000;

  emit( "\n=======================================================", true );
  emit( "\nMessageLogger service established\n" );
  emit( formatTime(time(0)), true );
  emit( "\n=======================================================\n", true );

}  // ELlog4cplus()
edm::ELlog4cplus::ELlog4cplus ( const ELlog4cplus orig)

Definition at line 119 of file ELlog4cplus.cc.

References dtNoiseDBValidation_cfg::cerr, edm::service::ELdestination::ignoreMostModules, edm::service::ELdestination::ignoreThese, edm::service::ELdestination::indent, edm::service::ELdestination::limits, edm::service::ELdestination::lineLength, edm::service::ELdestination::newline, osIsOwned, edm::service::ELdestination::preamble, edm::service::ELdestination::respondToMostModules, edm::service::ELdestination::respondToThese, edm::service::ELdestination::threshold, and edm::service::ELdestination::traceThreshold.

: ELdestination       (                           )
, os                  ( &os_                      )
, osIsOwned           ( orig.osIsOwned            )
, charsOnLine         ( orig.charsOnLine          )
, xid                 ( orig.xid                  )
, wantTimestamp       ( orig.wantTimestamp        )
, wantModule          ( orig.wantModule           )
, wantSubroutine      ( orig.wantSubroutine       )
, wantText            ( orig.wantText             )
, wantSomeContext     ( orig.wantSomeContext      )
, wantSerial          ( orig.wantSerial           )
, wantFullContext     ( orig.wantFullContext      )
, wantTimeSeparate    ( orig.wantTimeSeparate     )
, wantEpilogueSeparate( orig.wantEpilogueSeparate )
, xxxxInt             ( orig.xxxxInt              )
, appl_               ( orig.appl_                ) 
{

  #ifdef ELlog4cplusCONSTRUCTOR_TRACE
    std::cerr << "Copy constructor for ELlog4cplus\n";
  #endif

  // mf 6/15/01 fix of Bug 005
  threshold             = orig.threshold;
  traceThreshold        = orig.traceThreshold;

  limits                = orig.limits;
  preamble              = orig.preamble;
  newline               = orig.newline;
  indent                = orig.indent;
  lineLength            = orig.lineLength;

  ignoreMostModules     = orig.ignoreMostModules;
  respondToThese        = orig.respondToThese;
  respondToMostModules  = orig.respondToMostModules;
  ignoreThese           = orig.ignoreThese;

  // ownership, if any, passes to new copy:
  const_cast<ELlog4cplus &>(orig).osIsOwned = false;

}  // ELlog4cplus()
edm::ELlog4cplus::~ELlog4cplus ( ) [virtual]

Definition at line 163 of file ELlog4cplus.cc.

References dtNoiseDBValidation_cfg::cerr, os, and osIsOwned.

                           {

  #ifdef ELlog4cplusCONSTRUCTOR_TRACE
    std::cerr << "Destructor for ELlog4cplus\n";
  #endif

  if ( osIsOwned )  { // we have an ofstream
    ((std::ofstream*)os)->close();
    delete os;
  }

}  // ~ELlog4cplus()

Member Function Documentation

void edm::ELlog4cplus::attachEpilogue ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 495 of file ELlog4cplus.cc.

References wantEpilogueSeparate.

{ wantEpilogueSeparate = false; }
void edm::ELlog4cplus::attachTime ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 492 of file ELlog4cplus.cc.

References wantTimeSeparate.

{ wantTimeSeparate = false; }
ELlog4cplus * edm::ELlog4cplus::clone ( void  ) const [virtual]

Implements edm::service::ELdestination.

Definition at line 182 of file ELlog4cplus.cc.

References ELlog4cplus().

                          {

  return new ELlog4cplus( *this );

} // clone()
void edm::ELlog4cplus::emit ( const ELstring s,
bool  nl = false 
) [protected, virtual]

Definition at line 395 of file ELlog4cplus.cc.

References dtNoiseDBValidation_cfg::cerr, charsOnLine, edm::first(), edm::service::ELdestination::flush(), edm::service::ELdestination::indent, prof2calltree::last, edm::service::ELdestination::lineLength, edm::service::ELdestination::newline, alignCSCRings::s, and edm::second().

Referenced by ELlog4cplus(), log(), and summarization().

                                                     {

  #ifdef ELlog4cplus_EMIT_TRACE
    std::cerr << "[][][] in emit:  charsOnLine is " << charsOnLine << '\n';
    std::cerr << "[][][] in emit:  s.length() " << s.length() << '\n';
    std::cerr << "[][][] in emit:  lineLength is " << lineLength << '\n';
  #endif

  if (s.length() == 0)  {
    if ( nl )  {
      (*os) << newline << std::flush;
      charsOnLine = 0;
    }
    return;
  }

  char first = s[0];
  char second,
       last,
       last2;
  second = (s.length() < 2) ? '\0' : s[1];
  last = (s.length() < 2) ? '\0' : s[s.length()-1];
  last2 = (s.length() < 3) ? '\0' : s[s.length()-2];
         //checking -2 because the very last char is sometimes a ' ' inserted
         //by ErrorLog::operator<<

               //Accounts for newline @ the beginning of the ELstring     JV:2
  if ( first == '\n'
  || (charsOnLine + static_cast<int>(s.length())) > lineLength )  {
    #ifdef ELlog4cplus_EMIT_TRACE
      std::cerr << "[][][] in emit: about to << to *os \n";
    #endif
    (*os) << newline << indent;
    charsOnLine = indent.length();
    if (second != ' ')  {
      (*os) << ' ';
      charsOnLine++;
    }
    if ( first == '\n' )  {
      (*os) << s.substr(1);
    }
    else  {
      (*os) << s;
    }
  }

  #ifdef ELlog4cplus_EMIT_TRACE
    std::cerr << "[][][] in emit: about to << s to *os: " << s << " \n";
  #endif

  else  {
    (*os) << s;
  }

  if (last == '\n' || last2 == '\n')  {  //accounts for newline @ end    $$ JV:2
    (*os) << indent;                    //of the ELstring
    if (last != ' ')
      (*os) << ' ';
    charsOnLine = indent.length() + 1;
  }

  if ( nl )  { (*os) << newline << std::flush; charsOnLine = 0;           }
  else       {                                 charsOnLine += s.length(); }

  #ifdef ELlog4cplus_EMIT_TRACE
    std::cerr << "[][][] in emit: completed \n";
  #endif

}  // emit()
void edm::ELlog4cplus::includeContext ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 482 of file ELlog4cplus.cc.

References wantSomeContext.

{ wantSomeContext = true;  }
void edm::ELlog4cplus::includeModule ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 473 of file ELlog4cplus.cc.

References wantModule.

{ wantModule = true;  }
void edm::ELlog4cplus::includeSerial ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 486 of file ELlog4cplus.cc.

References wantSerial.

{ wantSerial = true;  }
void edm::ELlog4cplus::includeSubroutine ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 476 of file ELlog4cplus.cc.

References wantSubroutine.

{ wantSubroutine = true;  }
void edm::ELlog4cplus::includeText ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 479 of file ELlog4cplus.cc.

References wantText.

{ wantText = true;  }
void edm::ELlog4cplus::includeTime ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 470 of file ELlog4cplus.cc.

References wantTimestamp.

{ wantTimestamp = true;  }
bool edm::ELlog4cplus::log ( const ErrorObj msg) [virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 189 of file ELlog4cplus.cc.

References appl_, dtNoiseDBValidation_cfg::cerr, edm::ErrorObj::context(), edm::ELseverityLevel::ELsev_error, edm::ELseverityLevel::ELsev_info, edm::ELseverityLevel::ELsev_success, edm::ELseverityLevel::ELsev_warning, emit(), edm::formatTime(), edm::ELseverityLevel::getLevel(), edm::ELseverityLevel::getSymbol(), edm::ELextendedID::id, edm::ErrorObj::idOverflow(), instance, edm::service::ELadministrator::instance(), edm::ErrorObj::items(), edm::service::ELdestination::limits, edm::ELextendedID::module, os, edm::service::ELdestination::preamble, alignCSCRings::s, edm::ErrorObj::serial(), edm::ELextendedID::severity, edm::ELextendedID::subroutine, edm::service::ELdestination::thisShouldBeIgnored(), edm::service::ELdestination::threshold, edm::ErrorObj::timestamp(), edm::service::ELdestination::traceThreshold, wantEpilogueSeparate, wantFullContext, wantModule, wantSerial, wantSomeContext, wantSubroutine, wantText, wantTimeSeparate, wantTimestamp, edm::ErrorObj::xid(), and xid.

                                             {
  os->str(std::string());

  #ifdef ELlog4cplusTRACE_LOG
    std::cerr << "    =:=:=: Log to an ELlog4cplus \n";
  #endif

  xid = msg.xid();      // Save the xid.

  // See if this message is to be acted upon, and add it to limits table
  // if it was not already present:
  //
  if ( msg.xid().severity < threshold  )  return false;
  if ( thisShouldBeIgnored(xid.module) )  return false;
  if ( ! limits.add( msg.xid() )       )  return false;
  
#ifdef ELlog4cplusTRACE_LOG
  std::cerr << "    =:=:=: Limits table work done \n";
#endif
  
  // get log4cplus logger and establish (log4cplus) context 
  bool mustPop = false;

  log4cplus::Logger loghere = appl_ ? appl_->getApplicationLogger() :
    log4cplus::Logger::getInstance(msg.xid().module.c_str());
  LOG4CPLUS_DEBUG(loghere,  "Message2log4cplus will use logger from appl_ ? " 
                 << (appl_ ? "yes" : "no"));
  if(appl_)
    {
      log4cplus::getNDC().push(msg.xid().module.c_str());
      mustPop = true;
    }
  log4cplus::getNDC().push(msg.context().c_str());
  
  // Output the prologue:
  //
  emit( preamble );
  emit( xid.severity.getSymbol() );
  emit( " " );
  emit( xid.id );
  emit( msg.idOverflow() );
  emit( ": " );

  #ifdef ELlog4cplusTRACE_LOG
    std::cerr << "    =:=:=: Prologue done \n";
  #endif
  // Output serial number of message:
  //
  if ( wantSerial )  {
    std::ostringstream s;
    s << msg.serial();
    emit( "[serial #" + s.str() + ELstring("] ") );
  }

  // Output each item in the message:
  //
  if ( wantText )  {
    ELlist_string::const_iterator it;
    for ( it = msg.items().begin();  it != msg.items().end();  ++it )  {
    #ifdef ELlog4cplusTRACE_LOG
      std::cerr << "      =:=:=: Item:  " << *it << '\n';
    #endif
      emit( *it );
    }
  }

  // Provide further identification:
  //
  bool needAspace = true;
  if ( wantEpilogueSeparate )  {
    if ( xid.module.length() + xid.subroutine.length() > 0 )  {
      emit("\n");
      needAspace = false;
    }
    else if ( wantTimestamp && !wantTimeSeparate )  {
      emit("\n");
      needAspace = false;
    }
  }
  if ( wantModule && (xid.module.length() > 0) )  {
    if (needAspace) { emit(ELstring(" ")); needAspace = false; }
    emit( xid.module + ELstring(" ") );
  }
  if ( wantSubroutine && (xid.subroutine.length() > 0) )  {
    if (needAspace) { emit(ELstring(" ")); needAspace = false; }
    emit( xid.subroutine + "()" + ELstring(" ") );
  }

  #ifdef ELlog4cplusTRACE_LOG
    std::cerr << "    =:=:=: Module and Subroutine done \n";
  #endif

  // Provide time stamp:
  //
  if ( wantTimestamp )  {
    if ( wantTimeSeparate )  {
      emit( ELstring("\n") );
      needAspace = false;
    }
    if (needAspace) { emit(ELstring(" ")); needAspace = false; }
    emit( formatTime(msg.timestamp()) + ELstring(" ") );
  }

  #ifdef ELlog4cplusTRACE_LOG
    std::cerr << "    =:=:=: TimeStamp done \n";
  #endif

  // Provide the context information:
  //
  if ( wantSomeContext )
    if (needAspace) { emit(ELstring(" ")); needAspace = false; }
    #ifdef ELlog4cplusTRACE_LOG
      std::cerr << "    =:=:=:>> context supplier is at 0x"
                << std::hex
                << &service::ELadministrator::instance()->getContextSupplier() << '\n';
      std::cerr << "    =:=:=:>> context is --- "
                << service::ELadministrator::instance()->getContextSupplier().context()
                << '\n';
    #endif
    if ( wantFullContext )  {
      emit( service::ELadministrator::instance()->getContextSupplier().fullContext());
    #ifdef ELlog4cplusTRACE_LOG
      std::cerr << "    =:=:=: fullContext done: \n";
    #endif
    } else  {
      emit( service::ELadministrator::instance()->getContextSupplier().context());
  #ifdef ELlog4cplusTRACE_LOG
    std::cerr << "    =:=:=: Context done: \n";
  #endif
    }

  // Provide traceback information:
  //
  if ( msg.xid().severity >= traceThreshold )  {
    emit( ELstring("\n")
          + service::ELadministrator::instance()->getContextSupplier().traceRoutine()
        , true );
  }
  else  {                                        //else statement added JV:1
    emit ("", true);
  }
  #ifdef ELlog4cplusTRACE_LOG
    std::cerr << "    =:=:=: Trace routine done: \n";
  #endif

  // Done; message has been fully processed:
  //

  #ifdef ELlog4cplusTRACE_LOG
    std::cerr << "  =:=:=: log(msg) done: \n";
  #endif

    // std::cout << os->str() << "\n";

    switch(msg.xid().severity.getLevel())
      {
      case edm::ELseverityLevel::ELsev_success:
        {
          // success is used for debug here
          LOG4CPLUS_DEBUG(loghere,os->str());
          break;
        }
      case edm::ELseverityLevel::ELsev_info:
        {
          LOG4CPLUS_INFO(loghere,os->str());
          break;
        }
      case edm::ELseverityLevel::ELsev_warning:
        {
          LOG4CPLUS_WARN(loghere,os->str());
          break;
        }
      case edm::ELseverityLevel::ELsev_error:
      default:
        {
          LOG4CPLUS_ERROR(loghere,os->str());
          break;
        }
      }
    if(mustPop) log4cplus::getNDC().pop();
    log4cplus::getNDC().pop();
  return true;

}  // log()
ELlog4cplus& edm::ELlog4cplus::operator= ( const ELlog4cplus orig) [protected]
void edm::ELlog4cplus::separateEpilogue ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 494 of file ELlog4cplus.cc.

References wantEpilogueSeparate.

void edm::ELlog4cplus::separateTime ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 491 of file ELlog4cplus.cc.

References wantTimeSeparate.

{ wantTimeSeparate = true;  }
void edm::ELlog4cplus::setAppl ( xdaq::Application *  a)

Definition at line 531 of file ELlog4cplus.cc.

References a, appl_, and gather_cfg::cout.

Referenced by ML::MLlog4cplus::MLlog4cplus().

{
  std::cout << "setting application pointer in ELlog4cplus" << std::endl;
  appl_ = a;
}
void edm::ELlog4cplus::summarization ( const ELstring fullTitle,
const ELstring sumLines 
) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 502 of file ELlog4cplus.cc.

References emit(), geometryCSVtoXML::line, edm::service::ELdestination::lineLength, os, lumiQueryAPI::q, and indexGen::title.

   {
  const int titleMaxLength( 40 );

  // title:
  //
  ELstring title( fullTitle, 0, titleMaxLength );
  int q = (lineLength - title.length() - 2) / 2;
  ELstring line(q, '=');
  emit( "", true );
  emit( line );
  emit( " " );
  emit( title );
  emit( " " );
  emit( line, true );

  // body:
  //
  *os << sumLines;

  // finish:
  //
  emit( "", true );
  emit( ELstring(lineLength, '='), true );

}  // summarization()
void edm::ELlog4cplus::suppressContext ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 483 of file ELlog4cplus.cc.

References wantSomeContext.

{ wantSomeContext = false; }
void edm::ELlog4cplus::suppressModule ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 474 of file ELlog4cplus.cc.

References wantModule.

{ wantModule = false; }
void edm::ELlog4cplus::suppressSerial ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 485 of file ELlog4cplus.cc.

References wantSerial.

{ wantSerial = false; }
void edm::ELlog4cplus::suppressSubroutine ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 477 of file ELlog4cplus.cc.

References wantSubroutine.

{ wantSubroutine = false; }
void edm::ELlog4cplus::suppressText ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 480 of file ELlog4cplus.cc.

References wantText.

{ wantText = false; }
void edm::ELlog4cplus::suppressTime ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 471 of file ELlog4cplus.cc.

References wantTimestamp.

{ wantTimestamp = false; }
void edm::ELlog4cplus::useContext ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 489 of file ELlog4cplus.cc.

References wantFullContext.

{ wantFullContext = false; }
void edm::ELlog4cplus::useFullContext ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 488 of file ELlog4cplus.cc.

References wantFullContext.

{ wantFullContext = true;  }
void edm::ELlog4cplus::xxxxSet ( int  i)

Definition at line 382 of file ELlog4cplus.cc.

References i, and xxxxInt.

                                  {
  xxxxInt = i;
}
void edm::ELlog4cplus::xxxxShout ( )

Definition at line 386 of file ELlog4cplus.cc.

References dtNoiseDBValidation_cfg::cerr, and xxxxInt.

                             {
  std::cerr << "XXXX ELlog4cplus: " << xxxxInt << std::endl;
}

Friends And Related Function Documentation

friend class service::ELdestControl [friend]

Definition at line 53 of file ELlog4cplus.h.


Member Data Documentation

xdaq::Application* edm::ELlog4cplus::appl_ [private]

Definition at line 143 of file ELlog4cplus.h.

Referenced by log(), and setAppl().

Definition at line 120 of file ELlog4cplus.h.

Referenced by emit().

std::ostringstream* edm::ELlog4cplus::os [protected]

Definition at line 118 of file ELlog4cplus.h.

Referenced by log(), summarization(), and ~ELlog4cplus().

std::ostringstream edm::ELlog4cplus::os_ [protected]

Definition at line 117 of file ELlog4cplus.h.

bool edm::ELlog4cplus::osIsOwned [protected]

Definition at line 119 of file ELlog4cplus.h.

Referenced by ELlog4cplus(), and ~ELlog4cplus().

Definition at line 124 of file ELlog4cplus.h.

Referenced by attachEpilogue(), log(), and separateEpilogue().

Definition at line 124 of file ELlog4cplus.h.

Referenced by log(), useContext(), and useFullContext().

bool edm::ELlog4cplus::wantModule [protected]

Definition at line 124 of file ELlog4cplus.h.

Referenced by includeModule(), log(), and suppressModule().

bool edm::ELlog4cplus::wantSerial [protected]

Definition at line 124 of file ELlog4cplus.h.

Referenced by includeSerial(), log(), and suppressSerial().

Definition at line 124 of file ELlog4cplus.h.

Referenced by includeContext(), log(), and suppressContext().

Definition at line 124 of file ELlog4cplus.h.

Referenced by includeSubroutine(), log(), and suppressSubroutine().

bool edm::ELlog4cplus::wantText [protected]

Definition at line 124 of file ELlog4cplus.h.

Referenced by includeText(), log(), and suppressText().

Definition at line 124 of file ELlog4cplus.h.

Referenced by attachTime(), log(), and separateTime().

Definition at line 124 of file ELlog4cplus.h.

Referenced by includeTime(), log(), and suppressTime().

Definition at line 121 of file ELlog4cplus.h.

Referenced by log().

int edm::ELlog4cplus::xxxxInt [protected]

Definition at line 135 of file ELlog4cplus.h.

Referenced by xxxxSet(), and xxxxShout().