version 1.40, 2005/05/20 21:09:45
|
version 1.47, 2006/11/08 20:38:30
|
|
|
//%2005//////////////////////////////////////////////////////////////////////// |
//%2006//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development | // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. | // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
|
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. | // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; | // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
// EMC Corporation; VERITAS Software Corporation; The Open Group. | // EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; Symantec Corporation; The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// | // |
//============================================================================== | //============================================================================== |
// | // |
// Author: Mike Brasher (mbrasher@bmc.com) |
|
// |
|
// Modified By: Sushma Fernandes (Hewlett-Packard Company) |
|
// sushma_fernandes@hp.com |
|
// Modified By: Dave Rosckes (IBM) |
|
// rosckes@us.ibm.com |
|
// Amit K Arora, IBM (amita@in.ibm.com) for PEP101 |
|
// |
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include <iostream> | #include <iostream> |
|
|
#include "System.h" | #include "System.h" |
#include <Pegasus/Common/MessageLoader.h> //l10n | #include <Pegasus/Common/MessageLoader.h> //l10n |
| |
|
#if defined(PEGASUS_USE_SYSLOGS) |
|
# include <syslog.h> |
|
#endif |
|
|
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
|
|
"FATAL" | "FATAL" |
}; | }; |
| |
|
|
LoggerRep* Logger::_rep = 0; | LoggerRep* Logger::_rep = 0; |
String Logger::_homeDirectory = "."; | String Logger::_homeDirectory = "."; |
| |
|
|
{ | { |
"PegasusTrace.log", | "PegasusTrace.log", |
"PegasusStandard.log", | "PegasusStandard.log", |
|
"PegasusAudit.log", |
"PegasusError.log", | "PegasusError.log", |
"PegasusDebug.log" | "PegasusDebug.log" |
}; | }; |
|
|
fileName = _allocLogFileName(homeDirectory, Logger::STANDARD_LOG); | fileName = _allocLogFileName(homeDirectory, Logger::STANDARD_LOG); |
_logs[Logger::STANDARD_LOG].open(fileName, ios::app); | _logs[Logger::STANDARD_LOG].open(fileName, ios::app); |
| |
|
#ifndef PEGASUS_DISABLE_AUDIT_LOGGER |
|
fileName = _allocLogFileName(homeDirectory, Logger::AUDIT_LOG); |
|
_logs[Logger::AUDIT_LOG].open(fileName, ios::app); |
|
#endif |
|
|
fileName = _allocLogFileName(homeDirectory, Logger::ERROR_LOG); | fileName = _allocLogFileName(homeDirectory, Logger::ERROR_LOG); |
_logs[Logger::ERROR_LOG].open(fileName, ios::app); | _logs[Logger::ERROR_LOG].open(fileName, ios::app); |
| |
fileName = _allocLogFileName(homeDirectory, Logger::DEBUG_LOG); | fileName = _allocLogFileName(homeDirectory, Logger::DEBUG_LOG); |
_logs[Logger::DEBUG_LOG].open(fileName, ios::app); | _logs[Logger::DEBUG_LOG].open(fileName, ios::app); |
|
#else |
|
|
|
#ifdef PEGASUS_OS_ZOS |
|
logIdendity = System::CIMSERVER.getCString(); |
|
// If System Log is used open it |
|
System::openlog(logIdendity, LOG_PID, LOG_DAEMON); |
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
~LoggerRep() |
|
{ |
|
#if !defined(PEGASUS_USE_SYSLOGS) |
|
_logs[Logger::TRACE_LOG].close(); |
|
_logs[Logger::STANDARD_LOG].close(); |
|
|
|
#ifndef PEGASUS_DISABLE_AUDIT_LOGGER |
|
_logs[Logger::AUDIT_LOG].close(); |
|
#endif |
|
|
|
_logs[Logger::ERROR_LOG].close(); |
|
_logs[Logger::DEBUG_LOG].close(); |
|
|
|
#else |
|
|
|
#ifdef PEGASUS_OS_ZOS |
|
System::closelog(); |
|
|
|
#endif |
|
|
#endif | #endif |
| |
} | } |
|
|
{ | { |
int index = int(logFileType); | int index = int(logFileType); |
| |
if (index > int(Logger::ERROR_LOG)) |
if (index > int(Logger::NUM_LOGS)) |
index = Logger::ERROR_LOG; | index = Logger::ERROR_LOG; |
| |
return _logs[index]; | return _logs[index]; |
|
|
| |
private: | private: |
| |
|
#ifdef PEGASUS_OS_ZOS |
|
CString logIdendity; |
|
#endif |
ofstream _logs[int(Logger::NUM_LOGS)]; | ofstream _logs[int(Logger::NUM_LOGS)]; |
}; | }; |
| |
|
|
#if defined(PEGASUS_USE_SYSLOGS) | #if defined(PEGASUS_USE_SYSLOGS) |
| |
// Log the message | // Log the message |
System::syslog(System::CIMSERVER, logLevel, localizedMsg.getCString()); |
System::syslog(systemId, logLevel, localizedMsg.getCString()); |
| |
#else | #else |
| |
|
|
} | } |
} | } |
| |
#if 1 |
//////////////////////////////////////////////////////////////////////////////// |
|
// |
|
// Public methods start here: |
|
// |
|
//////////////////////////////////////////////////////////////////////////////// |
|
|
void Logger::put( | void Logger::put( |
LogFileType logFileType, | LogFileType logFileType, |
const String& systemId, | const String& systemId, |
|
|
const Formatter::Arg& arg8, | const Formatter::Arg& arg8, |
const Formatter::Arg& arg9) | const Formatter::Arg& arg9) |
{ | { |
Uint32 logComponent = 0; |
if (wouldLog(logLevel)) |
|
{ |
Logger::_putInternal(logFileType, systemId, logComponent, logLevel, |
Logger::_putInternal(logFileType, systemId, 0, logLevel, |
formatString, String::EMPTY, arg0, arg1, arg2, arg3, arg4, arg5, arg6, |
formatString, String::EMPTY, arg0, arg1, arg2, arg3, |
arg7, arg8, arg9); |
arg4, arg5, arg6, arg7, arg8, arg9); |
|
} |
} | } |
#endif |
|
| |
void Logger::put( | void Logger::put( |
LogFileType logFileType, | LogFileType logFileType, |
|
|
Uint32 logLevel, | Uint32 logLevel, |
const String& formatString) | const String& formatString) |
{ | { |
Uint32 logComponent = 0; |
if (wouldLog(logLevel)) |
|
{ |
Logger::_putInternal(logFileType, systemId, logComponent, logLevel, |
Logger::_putInternal(logFileType, systemId, 0, logLevel, |
formatString, String::EMPTY); | formatString, String::EMPTY); |
} | } |
|
} |
| |
void Logger::put( | void Logger::put( |
LogFileType logFileType, | LogFileType logFileType, |
|
|
const String& formatString, | const String& formatString, |
const Formatter::Arg& arg0) | const Formatter::Arg& arg0) |
{ | { |
Uint32 logComponent = 0; |
if (wouldLog(logLevel)) |
|
{ |
Logger::_putInternal(logFileType, systemId, logComponent, logLevel, |
Logger::_putInternal(logFileType, systemId, 0, logLevel, |
formatString, String::EMPTY, arg0); | formatString, String::EMPTY, arg0); |
} | } |
|
} |
|
|
|
void Logger::put( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
Uint32 logLevel, |
|
const String& formatString, |
|
const Formatter::Arg& arg0, |
|
const Formatter::Arg& arg1) |
|
{ |
|
if (wouldLog(logLevel)) |
|
{ |
|
Logger::_putInternal(logFileType, systemId, 0, logLevel, |
|
formatString, String::EMPTY, arg0, arg1); |
|
} |
|
} |
|
|
|
void Logger::put( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
Uint32 logLevel, |
|
const String& formatString, |
|
const Formatter::Arg& arg0, |
|
const Formatter::Arg& arg1, |
|
const Formatter::Arg& arg2) |
|
{ |
|
if (wouldLog(logLevel)) |
|
{ |
|
Logger::_putInternal(logFileType, systemId, 0, logLevel, |
|
formatString, String::EMPTY, arg0, arg1, arg2); |
|
} |
|
} |
| |
// l10n |
|
#if 1 |
|
void Logger::put_l( | void Logger::put_l( |
LogFileType logFileType, | LogFileType logFileType, |
const String& systemId, | const String& systemId, |
Uint32 logLevel, | Uint32 logLevel, |
const String& messageId, // l10n |
const String& messageId, |
const String& formatString, | const String& formatString, |
const Formatter::Arg& arg0, | const Formatter::Arg& arg0, |
const Formatter::Arg& arg1, | const Formatter::Arg& arg1, |
|
|
const Formatter::Arg& arg8, | const Formatter::Arg& arg8, |
const Formatter::Arg& arg9) | const Formatter::Arg& arg9) |
{ | { |
Uint32 logComponent = 0; |
if (wouldLog(logLevel)) |
|
{ |
Logger::_putInternal(logFileType, systemId, logComponent, logLevel, |
Logger::_putInternal(logFileType, systemId, 0, logLevel, |
formatString, messageId, arg0, arg1, arg2, arg3, arg4, arg5, | formatString, messageId, arg0, arg1, arg2, arg3, arg4, arg5, |
arg6, arg7, arg8, arg9); | arg6, arg7, arg8, arg9); |
} | } |
#endif |
} |
| |
void Logger::put_l( | void Logger::put_l( |
LogFileType logFileType, | LogFileType logFileType, |
|
|
const String& messageId, | const String& messageId, |
const String& formatString) | const String& formatString) |
{ | { |
Uint32 logComponent = 0; |
if (wouldLog(logLevel)) |
|
{ |
Logger::_putInternal(logFileType, systemId, logComponent, logLevel, |
Logger::_putInternal(logFileType, systemId, 0, logLevel, |
formatString, messageId); | formatString, messageId); |
} | } |
|
} |
| |
void Logger::put_l( | void Logger::put_l( |
LogFileType logFileType, | LogFileType logFileType, |
|
|
const String& formatString, | const String& formatString, |
const Formatter::Arg& arg0) | const Formatter::Arg& arg0) |
{ | { |
Uint32 logComponent = 0; |
if (wouldLog(logLevel)) |
|
{ |
Logger::_putInternal(logFileType, systemId, logComponent, logLevel, |
Logger::_putInternal(logFileType, systemId, 0, logLevel, |
formatString, messageId, arg0); | formatString, messageId, arg0); |
} | } |
|
} |
|
|
|
void Logger::put_l( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
Uint32 logLevel, |
|
const String& messageId, |
|
const String& formatString, |
|
const Formatter::Arg& arg0, |
|
const Formatter::Arg& arg1) |
|
{ |
|
if (wouldLog(logLevel)) |
|
{ |
|
Logger::_putInternal(logFileType, systemId, 0, logLevel, |
|
formatString, messageId, arg0, arg1); |
|
} |
|
} |
|
|
|
void Logger::put_l( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
Uint32 logLevel, |
|
const String& messageId, |
|
const String& formatString, |
|
const Formatter::Arg& arg0, |
|
const Formatter::Arg& arg1, |
|
const Formatter::Arg& arg2) |
|
{ |
|
if (wouldLog(logLevel)) |
|
{ |
|
Logger::_putInternal(logFileType, systemId, 0, logLevel, |
|
formatString, messageId, arg0, arg1, arg2); |
|
} |
|
} |
| |
void Logger::trace( | void Logger::trace( |
LogFileType logFileType, | LogFileType logFileType, |
|
|
const Formatter::Arg& arg8, | const Formatter::Arg& arg8, |
const Formatter::Arg& arg9) | const Formatter::Arg& arg9) |
{ | { |
Uint32 logLevel = Logger::TRACE; |
if (wouldLog(Logger::TRACE)) |
|
{ |
|
Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE, |
|
formatString, String::EMPTY, arg0, arg1, arg2, arg3, arg4, arg5, |
|
arg6, arg7, arg8, arg9); |
|
} |
|
} |
| |
Logger::_putInternal( |
void Logger::trace( |
logFileType, |
LogFileType logFileType, |
systemId, |
const String& systemId, |
logComponent, |
const Uint32 logComponent, |
logLevel, |
const String& formatString) |
formatString, |
{ |
// l10n |
if (wouldLog(Logger::TRACE)) |
String::EMPTY, |
{ |
arg0, |
Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE, |
arg1, |
formatString, String::EMPTY); |
arg2, |
} |
arg3, |
} |
arg4, |
|
arg5, |
void Logger::trace( |
arg6, |
LogFileType logFileType, |
arg7, |
const String& systemId, |
arg8, |
const Uint32 logComponent, |
arg9); |
const String& formatString, |
|
const Formatter::Arg& arg0) |
|
{ |
|
if (wouldLog(Logger::TRACE)) |
|
{ |
|
Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE, |
|
formatString, String::EMPTY, arg0); |
|
} |
|
} |
|
|
|
void Logger::trace( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
const Uint32 logComponent, |
|
const String& formatString, |
|
const Formatter::Arg& arg0, |
|
const Formatter::Arg& arg1) |
|
{ |
|
if (wouldLog(Logger::TRACE)) |
|
{ |
|
Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE, |
|
formatString, String::EMPTY, arg0, arg1); |
|
} |
|
} |
|
|
|
void Logger::trace( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
const Uint32 logComponent, |
|
const String& formatString, |
|
const Formatter::Arg& arg0, |
|
const Formatter::Arg& arg1, |
|
const Formatter::Arg& arg2) |
|
{ |
|
if (wouldLog(Logger::TRACE)) |
|
{ |
|
Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE, |
|
formatString, String::EMPTY, arg0, arg1, arg2); |
|
} |
} | } |
| |
// l10n |
|
void Logger::trace_l( | void Logger::trace_l( |
LogFileType logFileType, | LogFileType logFileType, |
const String& systemId, | const String& systemId, |
|
|
const Formatter::Arg& arg8, | const Formatter::Arg& arg8, |
const Formatter::Arg& arg9) | const Formatter::Arg& arg9) |
{ | { |
Uint32 logLevel = Logger::TRACE; |
if (wouldLog(Logger::TRACE)) |
|
{ |
|
Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE, |
|
formatString, messageId, arg0, arg1, arg2, arg3, arg4, arg5, arg6, |
|
arg7, arg8, arg9); |
|
} |
|
} |
| |
Logger::_putInternal( |
void Logger::trace_l( |
logFileType, |
LogFileType logFileType, |
systemId, |
const String& systemId, |
logComponent, |
const Uint32 logComponent, |
logLevel, |
const String& messageId, |
formatString, |
const String& formatString) |
messageId, |
{ |
arg0, |
if (wouldLog(Logger::TRACE)) |
arg1, |
{ |
arg2, |
Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE, |
arg3, |
formatString, messageId); |
arg4, |
} |
arg5, |
} |
arg6, |
|
arg7, |
void Logger::trace_l( |
arg8, |
LogFileType logFileType, |
arg9); |
const String& systemId, |
|
const Uint32 logComponent, |
|
const String& messageId, |
|
const String& formatString, |
|
const Formatter::Arg& arg0) |
|
{ |
|
if (wouldLog(Logger::TRACE)) |
|
{ |
|
Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE, |
|
formatString, messageId, arg0); |
|
} |
|
} |
|
|
|
void Logger::trace_l( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
const Uint32 logComponent, |
|
const String& messageId, |
|
const String& formatString, |
|
const Formatter::Arg& arg0, |
|
const Formatter::Arg& arg1) |
|
{ |
|
if (wouldLog(Logger::TRACE)) |
|
{ |
|
Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE, |
|
formatString, messageId, arg0, arg1); |
|
} |
|
} |
|
|
|
void Logger::trace_l( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
const Uint32 logComponent, |
|
const String& messageId, |
|
const String& formatString, |
|
const Formatter::Arg& arg0, |
|
const Formatter::Arg& arg1, |
|
const Formatter::Arg& arg2) |
|
{ |
|
if (wouldLog(Logger::TRACE)) |
|
{ |
|
Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE, |
|
formatString, messageId, arg0, arg1, arg2); |
|
} |
} | } |
| |
void Logger::setHomeDirectory(const String& homeDirectory) | void Logger::setHomeDirectory(const String& homeDirectory) |
|
|
_homeDirectory = homeDirectory; | _homeDirectory = homeDirectory; |
} | } |
| |
//////////////////////////////////////////////////////////////////////////////// |
|
// Set logLevel. |
|
//////////////////////////////////////////////////////////////////////////////// |
|
void Logger::setlogLevelMask( const String logLevelList ) | void Logger::setlogLevelMask( const String logLevelList ) |
{ | { |
Uint32 position = 0; | Uint32 position = 0; |
|
|
return ; | return ; |
} | } |
| |
Boolean Logger::isValidlogLevel( |
Boolean Logger::isValidlogLevel(const String logLevel) |
const String logLevel) |
|
{ | { |
// Validate the logLevel and modify the logLevel argument | // Validate the logLevel and modify the logLevel argument |
// to reflect the invalid logLevel | // to reflect the invalid logLevel |
|
|
return validlogLevel; | return validlogLevel; |
} | } |
| |
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
|
|