log_EventLogger Class Reference
[Event logging]

#include <eventlog.h>

Inheritance diagram for log_EventLogger:

Inheritance graph
[legend]
Collaboration diagram for log_EventLogger:

Collaboration graph
[legend]

List of all members.


Detailed Description

Definition at line 173 of file eventlog.h.


Public Member Functions

 log_EventLogger ()
virtual ~log_EventLogger ()
int SetNewPath (void)
void SetComponent (log_Component_e a_component)
void SetQualifier (const string &a_qualifier)
const char * GetComponent () const
const string & GetQualifier () const
void Write (string a_message, const string &a_subcomponent, UInt64_t a_jobID, const string &a_secID, evt_Status_e a_status)
string GetHeader () const

Private Attributes

 log_CLASSID_m
log_Component_e m_component
string m_qualifier

Static Private Attributes

static bool m_created = false
 Flag to guarantee singleton.

Constructor & Destructor Documentation

log_EventLogger::log_EventLogger (  ) 

Definition at line 127 of file log_eventlogger.cpp.

References ie_SINGLETON_EXISTS, IVD_COUT_LOG_m, ivd_Error, and m_created.

00128   :
00129     log_File(g_cmn.dirs.log + (g_cmn.prod.m_nameShortLC + ".log")),
00130     m_component(cmp_UNKNOWN),
00131     m_qualifier("") {
00132 
00133     IVD_COUT_LOG_m(" log_EventLogger::log_EventLogger() ")
00134     // Singleton check.
00135     if (m_created) {
00136         throw ivd_Error(ie_SINGLETON_EXISTS, "", true);
00137     }
00138     else {
00139         m_created = true;
00140     }
00141 }

log_EventLogger::~log_EventLogger (  )  [virtual]

Definition at line 143 of file log_eventlogger.cpp.

References IVD_COUT_LOG_m.

00143                                   {
00144     IVD_COUT_LOG_m(" log_EventLogger::~log_EventLogger() ")
00145     // Empty
00146 }


Member Function Documentation

int log_EventLogger::SetNewPath ( void   ) 

Definition at line 148 of file log_eventlogger.cpp.

References cmn_CreatePathNoException(), cmn_Global::dirs, g_cmn, IVD_COUT_LOG_m, ivd_Directories::log, log_File::m_fileName, ivd_Product::m_nameShortLC, and cmn_Global::prod.

00148                                    {
00149     IVD_COUT_LOG_m(" log_EventLogger::SetNewPath() ");
00150 
00151     m_fileName = g_cmn.dirs.log + (g_cmn.prod.m_nameShortLC + ".log");
00152     int result = cmn_CreatePathNoException(cmn_Path(g_cmn.dirs.log));
00153 
00154     if (result != 0) {
00155         cout
00156             << "** CRITICAL: log path can't be created: " << g_cmn.dirs.log << endl
00157             << "Events will not be logged." << endl
00158             << "Error: " << result;
00159     }
00160     return result;
00161 }

Here is the call graph for this function:

void log_EventLogger::SetComponent ( log_Component_e  a_component  ) 

Definition at line 188 of file log_eventlogger.cpp.

References m_component.

Referenced by log_EventLog::log_EventLog().

00188                                                               {
00189     m_component = a_component;
00190 }

Here is the caller graph for this function:

void log_EventLogger::SetQualifier ( const string &  a_qualifier  ) 

Definition at line 192 of file log_eventlogger.cpp.

References m_qualifier.

Referenced by log_EventLog::ChangeQualifier(), bea_TapeDrive::Close(), bea_DiskDrive::Close(), bea_TapeDrive::Open(), bea_DiskDrive::Open(), and i_BackEndAgent_i::UseResources().

00192                                                             {
00193     m_qualifier = a_qualifier;
00194 }

Here is the caller graph for this function:

const char * log_EventLogger::GetComponent (  )  const

Definition at line 254 of file log_eventlogger.cpp.

References cmn_GetComponentName(), g_cmn, m_component, m_created, ivd_Product::m_nameShort, NULL, and cmn_Global::prod.

Referenced by log_Output().

00254                                                 {
00255     static const char* s_ivd(g_cmn.prod.m_nameShort.c_str());
00256     if (!m_created) {
00257         return s_ivd;
00258     }
00259     const char* name = cmn_GetComponentName(m_component);
00260     if (name == NULL) {
00261         return s_ivd;
00262     }
00263     return name;
00264 }

Here is the call graph for this function:

Here is the caller graph for this function:

const string& log_EventLogger::GetQualifier (  )  const [inline]

Definition at line 184 of file eventlog.h.

Referenced by log_Output().

00184                                        {
00185         return m_qualifier;
00186     };

Here is the caller graph for this function:

void log_EventLogger::Write ( string  a_message,
const string &  a_subcomponent,
UInt64_t  a_jobID,
const string &  a_secID,
evt_Status_e  a_status 
)

Definition at line 196 of file log_eventlogger.cpp.

References cmn_GetComponentName(), dbg_LOW, evt_CRITICAL, evt_ERROR, evt_INFO, evt_WARNING, g_cmn, IVD_COUT_LOG_m, log_DBG_m, log_ERR_m, log_FUNC_m, log_WRN_m, m_component, m_qualifier, cmn_SysInfo::m_shortHostName, cmn_SysInfo::m_strpid, cmn_Global::si, cmn_Time::Time2YMDhms(), and log_File::WriteF().

Referenced by log_WriteEvent().

00201                               {
00202 
00203     log_FUNC_m(Write);
00204     IVD_COUT_LOG_m(" log_EventLogger::Write ")
00205 
00206     // Output to the event.log must be sequential (atomic).
00207     static cmn_Mutex errOut_x;
00208     cmn_MutexLock l (errOut_x);
00209 
00210     cmn_Time time;
00211 
00212     ostringstream sstr;
00213 
00214 //
00215 //[TIME, HOST, COMP:[SUBC], QUAL, [JOBID], [SECID]] [STATUS] Message
00216 //
00217 //[2002/03/19 16:39:06, cumulus, MIF:ADMJOB, ,200203210004, 9287-2342-24324] Started media volume init.
00218 //
00219     sstr
00220         << "["
00221         << time.Time2YMDhms() << ", "
00222         << g_cmn.si.m_shortHostName << ", "
00223         << g_cmn.si.m_strpid << ", "
00224         << cmn_GetComponentName(m_component)
00225         << (a_subcomponent.empty()? "" : string(":") + a_subcomponent) << ", "
00226         << m_qualifier << ", "
00227         << a_jobID << ", "
00228         << a_secID
00229         << "] ";
00230 
00231     switch (a_status) {
00232         case evt_WARNING:
00233             sstr << "WARNING: " << a_message << endl;
00234             log_WRN_m(sstr.str());
00235             break;
00236         case evt_ERROR:
00237             sstr << "ERROR: " << a_message << endl;
00238             log_ERR_m(sstr.str());
00239             break;
00240         case evt_CRITICAL:
00241             sstr << "CRITICAL ERROR: " << a_message << endl;
00242             log_ERR_m(sstr.str());
00243             break;
00244         case evt_INFO:
00245         default:
00246             sstr << a_message << endl;
00247             log_DBG_m(dbg_LOW, "$$ WriteEvent: " << endl << sstr.str());
00248             break;
00249     }
00250 
00251     WriteF(sstr.str());
00252 }

Here is the call graph for this function:

Here is the caller graph for this function:

string log_EventLogger::GetHeader (  )  const [virtual]

Reimplemented from log_File.

Definition at line 163 of file log_eventlogger.cpp.

References g_cmn, ivd_Versions::GetVersionString(), IVD_COUT_LOG_m, cmn_SysInfo::m_hostName, cmn_SysInfo::m_ip, cmn_SysInfo::m_machine, ivd_Product::m_nameShort, cmn_SysInfo::m_officialHostName, cmn_SysInfo::m_officialIP, cmn_SysInfo::m_osName, cmn_SysInfo::m_osRelease, cmn_SysInfo::m_osVersion, cmn_Global::prod, cmn_Global::si, and cmn_Time::Time2YMDhms().

00163                                         {
00164     IVD_COUT_LOG_m(" log_EventLogger::WriteHeader() ")
00165     cmn_Time    m_time;
00166     ostringstream sstr;
00167     sstr
00168         << "=============================================" << endl
00169         << " "                << g_cmn.prod.m_nameShort
00170         << " Event log file"  << endl << endl
00171         << " Hostname (IP): " << g_cmn.si.m_hostName << " ("
00172                               << g_cmn.si.m_ip << "), official: "
00173                               << g_cmn.si.m_officialHostName << " ("
00174                               << g_cmn.si.m_officialIP << ")" << endl
00175         << " OS           : " << g_cmn.si.m_osName << " ("
00176                               << g_cmn.si.m_osRelease << ","
00177                               << g_cmn.si.m_osVersion << ") on "
00178                               << g_cmn.si.m_machine << endl
00179         << " Created by   : " << endl
00180                               << ivd_Versions::GetVersionString() << endl
00181         << " Create time  : " << m_time.Time2YMDhms() << endl
00182         << "============================================="
00183         << endl << endl;
00184     return sstr.str();
00185 }

Here is the call graph for this function:


Member Data Documentation

Definition at line 198 of file eventlog.h.

bool log_EventLogger::m_created = false [static, private]

Flag to guarantee singleton.

Definition at line 201 of file eventlog.h.

Referenced by GetComponent(), and log_EventLogger().

Definition at line 203 of file eventlog.h.

Referenced by GetComponent(), SetComponent(), and Write().

string log_EventLogger::m_qualifier [private]

Definition at line 204 of file eventlog.h.

Referenced by SetQualifier(), and Write().


The documentation for this class was generated from the following files:

Generated on Mon Feb 27 19:42:43 2012 for OPENARCHIVE by  doxygen 1.5.6