version 1.103, 2005/05/16 17:18:34
|
version 1.104, 2005/05/20 21:09:45
|
|
|
// Sushma Fernandes (sushma_fernandes@hp.com) | // Sushma Fernandes (sushma_fernandes@hp.com) |
// Nag Boranna (nagaraja_boranna@hp.com) | // Nag Boranna (nagaraja_boranna@hp.com) |
// Bapu Patil (bapu_patil@hp.com) | // Bapu Patil (bapu_patil@hp.com) |
// |
// Dave Rosckes (rosckes@us.ibm.com) |
// Modified By: Dave Rosckes (rosckes@us.ibm.com) |
|
// Amit K Arora (amita@in.ibm.com) for PEP101 | // Amit K Arora (amita@in.ibm.com) for PEP101 |
// David Dillard, VERITAS Software Corp. | // David Dillard, VERITAS Software Corp. |
// (david.dillard@veritas.com) | // (david.dillard@veritas.com) |
// Yi Zhou (yi.zhou@hp.com) | // Yi Zhou (yi.zhou@hp.com) |
// Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) for Bug#3194 | // Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) for Bug#3194 |
|
// Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
#include "System.h" | #include "System.h" |
#include <Pegasus/Common/Tracer.h> | #include <Pegasus/Common/Tracer.h> |
#include <Pegasus/Common/InternalException.h> | #include <Pegasus/Common/InternalException.h> |
|
#include <Pegasus/Common/IPC.h> |
#ifdef PEGASUS_ZOS_SECURITY | #ifdef PEGASUS_ZOS_SECURITY |
#include "DynamicLibraryzOS_inline.h" | #include "DynamicLibraryzOS_inline.h" |
#endif | #endif |
|
|
return (st.st_uid == geteuid()); | return (st.st_uid == geteuid()); |
} | } |
| |
void System::openlog(const String &ident) |
void System::syslog(const String& ident, Uint32 severity, const char* message) |
{ | { |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) |
::openlog(ident.getCString(), LOG_PID, LOG_DAEMON); |
|
| |
#endif |
// Since the openlog(), syslog(), and closelog() function calls must be |
|
// coordinated (see below), we need a thread control. |
| |
return; |
static Mutex logMutex; |
} |
|
|
AutoMutex loglock(logMutex); |
|
|
|
// Get a const char* representation of the identifier string. Note: The |
|
// character string passed to the openlog() function must persist until |
|
// closelog() is called. The syslog() method uses this pointer directly |
|
// rather than a copy of the string it refers to. |
|
|
|
CString identCString = ident.getCString(); |
|
openlog(identCString, LOG_PID, LOG_DAEMON); |
| |
void System::syslog(Uint32 severity, const char *data) |
// Map from the Logger log level to the system log level. |
|
|
|
Uint32 syslogLevel; |
|
if (severity & Logger::FATAL) |
|
{ |
|
syslogLevel = LOG_CRIT; |
|
} |
|
else if (severity & Logger::SEVERE) |
|
{ |
|
syslogLevel = LOG_ERR; |
|
} |
|
else if (severity & Logger::WARNING) |
|
{ |
|
syslogLevel = LOG_WARNING; |
|
} |
|
else if (severity & Logger::INFORMATION) |
|
{ |
|
syslogLevel = LOG_INFO; |
|
} |
|
else // if (severity & Logger::TRACE) |
{ | { |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) |
syslogLevel = LOG_DEBUG; |
|
} |
| |
// FUTURE-SF-P3-20020517 : Use the Syslog on HP-UX. Eventually only |
// Write the message to the system log. |
// certain messages will go to the Syslog and others to the |
|
// Pegasus Logger. |
|
Uint32 syslogLevel = LOG_DEBUG; |
|
| |
// Map the log levels. |
::syslog(syslogLevel, "%s", message); |
if (severity & Logger::TRACE) syslogLevel = LOG_DEBUG; |
|
if (severity & Logger::INFORMATION) syslogLevel = LOG_INFO; |
|
if (severity & Logger::WARNING) syslogLevel = LOG_WARNING; |
|
if (severity & Logger::SEVERE) syslogLevel = LOG_ERR; |
|
if (severity & Logger::FATAL) syslogLevel = LOG_CRIT; |
|
| |
::syslog(syslogLevel, "%s", data); |
closelog(); |
| |
#elif defined(PEGASUS_OS_OS400) | #elif defined(PEGASUS_OS_OS400) |
| |
std::string replacementData = data; |
std::string replacementData = message; |
// All messages will go to the joblog. In the future | // All messages will go to the joblog. In the future |
// some messages may go to other message queues yet | // some messages may go to other message queues yet |
// to be determined. | // to be determined. |
|
|
// turn into ycmMessage so we can put it in the job log | // turn into ycmMessage so we can put it in the job log |
#pragma convert(37) | #pragma convert(37) |
ycmMessage theMessage("CPIDF80", | ycmMessage theMessage("CPIDF80", |
data, |
message, |
strlen(data), |
strlen(message), |
"Logger", | "Logger", |
ycmCTLCIMID, | ycmCTLCIMID, |
TRUE); | TRUE); |
|
|
// turn into ycmMessage so we can put it in the job log | // turn into ycmMessage so we can put it in the job log |
#pragma convert(37) | #pragma convert(37) |
ycmMessage theMessage("CPDDF82", | ycmMessage theMessage("CPDDF82", |
data, |
message, |
strlen(data), |
strlen(message), |
"Logger", | "Logger", |
ycmCTLCIMID, | ycmCTLCIMID, |
TRUE); | TRUE); |
|
|
} | } |
| |
#endif | #endif |
|
|
return; |
|
} |
|
|
|
void System::closelog() |
|
{ |
|
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) |
|
|
|
::closelog(); |
|
|
|
#endif |
|
|
|
return; |
|
} | } |
| |
// System ID constants for Logger::put and Logger::trace | // System ID constants for Logger::put and Logger::trace |