Public Member Functions | Private Attributes | Static Private Attributes

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.

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.

Detailed Description

Definition at line 187 of file eventlog.h.


Constructor & Destructor Documentation

log_EventLogger::log_EventLogger (  ) 

Definition at line 141 of file log_eventlogger.cpp.

References ie_SINGLETON_EXISTS, IVD_COUT_LOG_m, ivd_Error, and m_created.

  :
    log_File(g_cmn.dirs.log + (g_cmn.prod.m_nameShortLC + ".log")),
    m_component(cmp_UNKNOWN),
    m_qualifier("") {

    IVD_COUT_LOG_m(" log_EventLogger::log_EventLogger() ")
    // Singleton check.
    if (m_created) {
        throw ivd_Error(ie_SINGLETON_EXISTS, "", true);
    }
    else {
        m_created = true;
    }
}

log_EventLogger::~log_EventLogger (  )  [virtual]

Definition at line 157 of file log_eventlogger.cpp.

References IVD_COUT_LOG_m.

                                  {
    IVD_COUT_LOG_m(" log_EventLogger::~log_EventLogger() ")
    // Empty
}


Member Function Documentation

const char * log_EventLogger::GetComponent (  )  const

Definition at line 268 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().

                                                {
    static const char* s_ivd(g_cmn.prod.m_nameShort.c_str());
    if (!m_created) {
        return s_ivd;
    }
    const char* name = cmn_GetComponentName(m_component);
    if (name == NULL) {
        return s_ivd;
    }
    return name;
}

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 177 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().

                                        {
    IVD_COUT_LOG_m(" log_EventLogger::WriteHeader() ")
    cmn_Time    m_time;
    ostringstream sstr;
    sstr
        << "=============================================" << endl
        << " "                << g_cmn.prod.m_nameShort
        << " Event log file"  << endl << endl
        << " Hostname (IP): " << g_cmn.si.m_hostName << " ("
                              << g_cmn.si.m_ip << "), official: "
                              << g_cmn.si.m_officialHostName << " ("
                              << g_cmn.si.m_officialIP << ")" << endl
        << " OS           : " << g_cmn.si.m_osName << " ("
                              << g_cmn.si.m_osRelease << ","
                              << g_cmn.si.m_osVersion << ") on "
                              << g_cmn.si.m_machine << endl
        << " Created by   : " << endl
                              << ivd_Versions::GetVersionString() << endl
        << " Create time  : " << m_time.Time2YMDhms() << endl
        << "============================================="
        << endl << endl;
    return sstr.str();
}

Here is the call graph for this function:

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

Definition at line 198 of file eventlog.h.

Referenced by log_Output().

                                       {
        return m_qualifier;
    };

Here is the caller graph for this function:

void log_EventLogger::SetComponent ( log_Component_e  a_component  ) 

Definition at line 202 of file log_eventlogger.cpp.

References m_component.

Referenced by log_EventLog::log_EventLog().

                                                              {
    m_component = a_component;
}

Here is the caller graph for this function:

int log_EventLogger::SetNewPath ( void   ) 

Definition at line 162 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.

                                   {
    IVD_COUT_LOG_m(" log_EventLogger::SetNewPath() ");

    m_fileName = g_cmn.dirs.log + (g_cmn.prod.m_nameShortLC + ".log");
    int result = cmn_CreatePathNoException(cmn_Path(g_cmn.dirs.log));

    if (result != 0) {
        cout
            << "** CRITICAL: log path can't be created: " << g_cmn.dirs.log << endl
            << "Events will not be logged." << endl
            << "Error: " << result;
    }
    return result;
}

Here is the call graph for this function:

void log_EventLogger::SetQualifier ( const string &  a_qualifier  ) 

Definition at line 206 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().

                                                            {
    m_qualifier = a_qualifier;
}

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 210 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().

                              {

    log_FUNC_m(Write);
    IVD_COUT_LOG_m(" log_EventLogger::Write ")

    // Output to the event.log must be sequential (atomic).
    static cmn_Mutex errOut_x;
    cmn_MutexLock l (errOut_x);

    cmn_Time time;

    ostringstream sstr;

//
//[TIME, HOST, COMP:[SUBC], QUAL, [JOBID], [SECID]] [STATUS] Message
//
//[2002/03/19 16:39:06, cumulus, MIF:ADMJOB, ,200203210004, 9287-2342-24324] Started media volume init.
//
    sstr
        << "["
        << time.Time2YMDhms() << ", "
        << g_cmn.si.m_shortHostName << ", "
        << g_cmn.si.m_strpid << ", "
        << cmn_GetComponentName(m_component)
        << (a_subcomponent.empty()? "" : string(":") + a_subcomponent) << ", "
        << m_qualifier << ", "
        << a_jobID << ", "
        << a_secID
        << "] ";

    switch (a_status) {
        case evt_WARNING:
            sstr << "WARNING: " << a_message << endl;
            log_WRN_m(sstr.str());
            break;
        case evt_ERROR:
            sstr << "ERROR: " << a_message << endl;
            log_ERR_m(sstr.str());
            break;
        case evt_CRITICAL:
            sstr << "CRITICAL ERROR: " << a_message << endl;
            log_ERR_m(sstr.str());
            break;
        case evt_INFO:
        default:
            sstr << a_message << endl;
            log_DBG_m(dbg_LOW, "$$ WriteEvent: " << endl << sstr.str());
            break;
    }

    WriteF(sstr.str());
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 212 of file eventlog.h.

Definition at line 217 of file eventlog.h.

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

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

Flag to guarantee singleton.

Definition at line 215 of file eventlog.h.

Referenced by GetComponent(), and log_EventLogger().

string log_EventLogger::m_qualifier [private]

Definition at line 218 of file eventlog.h.

Referenced by SetQualifier(), and Write().


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