version 1.46, 2006/11/03 18:31:40
|
version 1.68, 2008/12/16 18:56:00
|
|
|
//%2006//////////////////////////////////////////////////////////////////////// |
//%LICENSE//////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Licensed to The Open Group (TOG) under one or more contributor license |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
// agreements. Refer to the OpenPegasusNOTICE.txt file distributed with |
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; |
// this work for additional information regarding copyright ownership. |
// IBM Corp.; EMC Corporation, The Open Group. |
// Each contributor licenses this file to you under the OpenPegasus Open |
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
// Source License; you may not use this file except in compliance with the |
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
// License. |
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// 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 |
|
// of this software and associated documentation files (the "Software"), to |
|
// deal in the Software without restriction, including without limitation the |
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
|
// sell copies of the Software, and to permit persons to whom the Software is |
|
// furnished to do so, subject to the following conditions: |
|
// |
|
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN |
|
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED |
|
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT |
|
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
|
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
|
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
// | // |
//============================================================================== |
// Permission is hereby granted, free of charge, to any person obtaining a |
|
// copy of this software and associated documentation files (the "Software"), |
|
// to deal in the Software without restriction, including without limitation |
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense, |
|
// and/or sell copies of the Software, and to permit persons to whom the |
|
// Software is furnished to do so, subject to the following conditions: |
|
// |
|
// The above copyright notice and this permission notice shall be included |
|
// in all copies or substantial portions of the Software. |
|
// |
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
// |
|
////////////////////////////////////////////////////////////////////////// |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include <iostream> | #include <iostream> |
#include <fstream> | #include <fstream> |
#include <cstring> | #include <cstring> |
#include "Logger.h" |
#include <Pegasus/Common/Logger.h> |
#include "System.h" |
#include <Pegasus/Common/Tracer.h> |
#include <Pegasus/Common/MessageLoader.h> //l10n |
#include <Pegasus/Common/System.h> |
|
#include <Pegasus/Common/FileSystem.h> |
|
#include <Pegasus/Common/MessageLoader.h> |
|
#include <Pegasus/Common/Executor.h> |
|
#include <Pegasus/Common/Mutex.h> |
|
|
|
#if defined(PEGASUS_USE_SYSLOGS) |
|
# include <syslog.h> |
|
#endif |
| |
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
const Uint32 Logger::TRACE = (1 << 0); | const Uint32 Logger::TRACE = (1 << 0); |
const Uint32 Logger::INFORMATION = (1 << 1); | const Uint32 Logger::INFORMATION = (1 << 1); |
const Uint32 Logger::WARNING = (1 << 2); | const Uint32 Logger::WARNING = (1 << 2); |
|
|
| |
const Uint32 Logger::_NUM_LOGLEVEL = 5; | const Uint32 Logger::_NUM_LOGLEVEL = 5; |
| |
// Set separator |
|
const char Logger::_SEPARATOR = '@'; |
|
|
|
Uint32 Logger::_severityMask; | Uint32 Logger::_severityMask; |
| |
Uint32 Logger::_writeControlMask = 0xF; // Set all on by default |
|
| |
// Set the return codes |
/////////////////////////////////////////////////////////////////////////////// |
const Boolean Logger::_SUCCESS = 1; |
// |
const Boolean Logger::_FAILURE = 0; |
// LoggerRep |
|
// |
/* _allocLogFileName. Allocates the name from a name set. |
/////////////////////////////////////////////////////////////////////////////// |
Today this is static. However, it should be completely |
|
configerable and driven from the config file so that |
#if defined(PEGASUS_USE_SYSLOGS) |
Log organization and names are open. |
|
ATTN: rewrite this so that names, choice to do logs and |
class LoggerRep |
mask for level of severity are all driven from configuration |
|
input. |
|
*/ |
|
static CString _allocLogFileName( |
|
const String& homeDirectory, |
|
Logger::LogFileType logFileType) |
|
{ | { |
|
public: |
|
|
|
LoggerRep(const String& homeDirectory) |
|
{ |
|
# ifdef PEGASUS_OS_ZOS |
|
logIdentity = strdup(System::CIMSERVER.getCString()); |
|
// If System Log is used open it |
|
System::openlog(logIdentity, LOG_PID, LOG_DAEMON); |
|
# endif |
|
} |
|
|
|
~LoggerRep() |
|
{ |
|
# ifdef PEGASUS_OS_ZOS |
|
System::closelog(); |
|
free(logIdentity); |
|
# endif |
|
} |
|
|
|
// Actual logging is done in this routine |
|
void log(Logger::LogFileType logFileType, |
|
const String& systemId, |
|
Uint32 logLevel, |
|
const String localizedMsg) |
|
{ |
|
// Log the message |
|
System::syslog(systemId, logLevel, localizedMsg.getCString()); |
|
} |
|
|
|
private: |
|
|
|
# ifdef PEGASUS_OS_ZOS |
|
char* logIdentity; |
|
# endif |
|
}; |
|
|
|
#else // !defined(PEGASUS_USE_SYSLOGS) |
|
|
static const char* fileNames[] = | static const char* fileNames[] = |
{ | { |
"PegasusTrace.log", | "PegasusTrace.log", |
"PegasusStandard.log", | "PegasusStandard.log", |
"PegasusAudit.log", | "PegasusAudit.log", |
"PegasusError.log", |
"PegasusError.log" |
"PegasusDebug.log" |
|
}; | }; |
|
static const char* lockFileName = "PegasusLog.lock"; |
| |
int index = int(logFileType); |
/* |
|
_constructFileName builds the absolute file name from homeDirectory |
if (index > Logger::NUM_LOGS) |
and fileName. |
index = Logger::ERROR_LOG; |
*/ |
|
static CString _constructFileName( |
const char* logFileName = fileNames[index]; |
const String& homeDirectory, |
|
const char * fileName) |
|
{ |
String result; | String result; |
result.reserveCapacity(homeDirectory.size() + 1 + strlen(logFileName)); |
result.reserveCapacity( |
|
(Uint32)(homeDirectory.size() + 1 + strlen(fileName))); |
result.append(homeDirectory); | result.append(homeDirectory); |
result.append('/'); | result.append('/'); |
result.append(logFileName); |
result.append(fileName); |
return result.getCString(); | return result.getCString(); |
} | } |
| |
|
|
| |
LoggerRep(const String& homeDirectory) | LoggerRep(const String& homeDirectory) |
{ | { |
#if !defined(PEGASUS_USE_SYSLOGS) |
|
// Add test for home directory set. | // Add test for home directory set. |
| |
// If home directory does not exist, create it. | // If home directory does not exist, create it. |
|
|
| |
// KS: I put the second test in just in case some trys to create | // KS: I put the second test in just in case some trys to create |
// a completly erronous directory. At least we will get a message | // a completly erronous directory. At least we will get a message |
if (!System::isDirectory(lgDir)){ |
if (!System::isDirectory(lgDir)) |
//l10n |
{ |
//cerr << "Logging Disabled"; |
|
MessageLoaderParms parms("Common.Logger.LOGGING_DISABLED", | MessageLoaderParms parms("Common.Logger.LOGGING_DISABLED", |
"Logging Disabled"); | "Logging Disabled"); |
| |
cerr << MessageLoader::getMessage(parms); | cerr << MessageLoader::getMessage(parms); |
} | } |
| |
CString fileName = _allocLogFileName(homeDirectory, Logger::TRACE_LOG); |
//Filelocks are not used for VMS |
_logs[Logger::TRACE_LOG].open(fileName, ios::app); |
# if !defined(PEGASUS_OS_VMS) |
|
_loggerLockFileName = _constructFileName(homeDirectory, lockFileName); |
fileName = _allocLogFileName(homeDirectory, Logger::STANDARD_LOG); |
|
_logs[Logger::STANDARD_LOG].open(fileName, ios::app); |
// Open and close a file to make sure that the file exists, on which |
|
// file lock is requested |
#ifndef PEGASUS_DISABLE_AUDIT_LOGGER |
FILE *fileLockFilePointer; |
fileName = _allocLogFileName(homeDirectory, Logger::AUDIT_LOG); |
fileLockFilePointer = fopen(_loggerLockFileName, "a+"); |
_logs[Logger::AUDIT_LOG].open(fileName, ios::app); |
if(fileLockFilePointer) |
|
{ |
|
fclose(fileLockFilePointer); |
|
} |
#endif | #endif |
| |
fileName = _allocLogFileName(homeDirectory, Logger::ERROR_LOG); |
_logFileNames[Logger::TRACE_LOG] = _constructFileName(homeDirectory, |
_logs[Logger::ERROR_LOG].open(fileName, ios::app); |
fileNames[Logger::TRACE_LOG]); |
|
|
|
_logFileNames[Logger::STANDARD_LOG] = _constructFileName(homeDirectory, |
|
fileNames[Logger::STANDARD_LOG]); |
| |
fileName = _allocLogFileName(homeDirectory, Logger::DEBUG_LOG); |
# ifdef PEGASUS_ENABLE_AUDIT_LOGGER |
_logs[Logger::DEBUG_LOG].open(fileName, ios::app); |
_logFileNames[Logger::AUDIT_LOG] = _constructFileName(homeDirectory, |
|
fileNames[Logger::AUDIT_LOG]); |
#endif | #endif |
| |
|
_logFileNames[Logger::ERROR_LOG] = _constructFileName(homeDirectory, |
|
fileNames[Logger::ERROR_LOG]); |
} | } |
| |
ostream& logOf(Logger::LogFileType logFileType) |
~LoggerRep() |
{ | { |
int index = int(logFileType); |
|
|
|
if (index > int(Logger::NUM_LOGS)) |
|
index = Logger::ERROR_LOG; |
|
|
|
return _logs[index]; |
|
} | } |
| |
private: |
// Actual logging is done in this routine |
|
void log(Logger::LogFileType logFileType, |
ofstream _logs[int(Logger::NUM_LOGS)]; |
|
}; |
|
|
|
void Logger::_putInternal( |
|
LogFileType logFileType, |
|
const String& systemId, | const String& systemId, |
const Uint32 logComponent, // TODO: Support logComponent mask in future release |
|
Uint32 logLevel, | Uint32 logLevel, |
const String& formatString, |
const String localizedMsg) |
const String& messageId, // l10n |
|
const Formatter::Arg& arg0, |
|
const Formatter::Arg& arg1, |
|
const Formatter::Arg& arg2, |
|
const Formatter::Arg& arg3, |
|
const Formatter::Arg& arg4, |
|
const Formatter::Arg& arg5, |
|
const Formatter::Arg& arg6, |
|
const Formatter::Arg& arg7, |
|
const Formatter::Arg& arg8, |
|
const Formatter::Arg& arg9) |
|
{ |
|
// Test for logLevel against severity mask to determine |
|
// if we write this log. |
|
if ((_severityMask & logLevel) != 0) |
|
{ | { |
if (!_rep) |
// Prepend the systemId to the incoming message |
_rep = new LoggerRep(_homeDirectory); |
String messageString(systemId); |
|
messageString.append(": "); |
|
messageString.append(localizedMsg); // l10n |
| |
// Get the logLevel String | // Get the logLevel String |
// This converts bitmap to string based on highest order | // This converts bitmap to string based on highest order |
// bit set | // bit set |
// ATTN: KS Fix this more efficiently. | // ATTN: KS Fix this more efficiently. |
static const char* svNames[] = |
const char* tmp = ""; |
|
if (logLevel & Logger::TRACE) tmp = "TRACE "; |
|
if (logLevel & Logger::INFORMATION) tmp = "INFO "; |
|
if (logLevel & Logger::WARNING) tmp = "WARNING "; |
|
if (logLevel & Logger::SEVERE) tmp = "SEVERE "; |
|
if (logLevel & Logger::FATAL) tmp = "FATAL "; |
|
|
|
# ifndef PEGASUS_OS_VMS |
|
// Acquire AutoMutex (for thread sync) |
|
// and AutoFileLock (for Process Sync). |
|
AutoMutex am(_mutex); |
|
AutoFileLock fileLock(_loggerLockFileName); |
|
|
|
Uint32 logFileSize = 0; |
|
|
|
// Read logFileSize to check if the logfile needs to be pruned. |
|
FileSystem::getFileSize(String(_logFileNames[logFileType]), |
|
logFileSize); |
|
|
|
// Check if the size of the logfile is exceeding _maxLogFileSizeBytes. |
|
if ( logFileSize > _maxLogFileSizeBytes) |
{ | { |
"TRACE ", |
// Prepare appropriate file name based on the logFileType. |
"INFO ", |
// Eg: if Logfile name is PegasusStandard.log, pruned logfile name |
"WARNING ", |
// will be PegasusStandard-062607-122302.log,where 062607-122302 |
"SEVERE ", |
// is the time stamp. |
"FATAL " |
String prunedLogfile(_logFileNames[logFileType], |
}; |
(Uint32)strlen(_logFileNames[logFileType]) - 4); |
// NUM_LEVELS = 5 |
prunedLogfile.append('-'); |
int sizeSvNames = sizeof(svNames) / sizeof(svNames[0]) - 1; |
|
| |
// l10n start |
// Get timestamp,remove illegal chars in file name'/' and ':' |
// The localized message to be sent to the system log. |
// (: is illegal Open VMS) from the time stamp. Append the time |
String localizedMsg; |
// info to the file name. |
|
|
// If the caller specified a messageId, then load the localized |
|
// message in the locale of the server process. |
|
if (messageId != String::EMPTY) |
|
{ |
|
// A message ID was specified. Use the MessageLoader. |
|
MessageLoaderParms msgParms(messageId, formatString); |
|
msgParms.useProcessLocale = true; |
|
msgParms.arg0 = arg0; |
|
msgParms.arg1 = arg1; |
|
msgParms.arg2 = arg2; |
|
msgParms.arg3 = arg3; |
|
msgParms.arg4 = arg4; |
|
msgParms.arg5 = arg5; |
|
msgParms.arg6 = arg6; |
|
msgParms.arg7 = arg7; |
|
msgParms.arg8 = arg8; |
|
msgParms.arg9 = arg9; |
|
| |
localizedMsg = MessageLoader::getMessage(msgParms); |
String timeStamp = System::getCurrentASCIITime(); |
|
for (unsigned int i=0; i<=timeStamp.size(); i++) |
|
{ |
|
if(timeStamp[i] == '/' || timeStamp[i] == ':') |
|
{ |
|
timeStamp.remove(i, 1); |
} | } |
else |
|
{ // No message ID. Use the Pegasus formatter |
|
localizedMsg = Formatter::format(formatString, |
|
arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); |
|
} | } |
// l10n end |
prunedLogfile.append(timeStamp); |
| |
#if defined(PEGASUS_USE_SYSLOGS) |
// Append '.log' to the file |
|
prunedLogfile.append( ".log"); |
| |
// Log the message |
// Rename the logfile |
System::syslog(systemId, logLevel, localizedMsg.getCString()); |
FileSystem::renameFile(String(_logFileNames[logFileType]), |
|
prunedLogfile); |
| |
#else |
} // Check if the logfile needs to be pruned. |
|
# endif // ifndef PEGASUS_OS_VMS |
| |
// Prepend the systemId to the incoming message |
// Open Logfile. Based on the value of logFileType, one of the five |
String messageString(systemId); |
// Logfiles will be opened. |
messageString.append(": "); |
ofstream logFileStream; |
messageString.append(localizedMsg); // l10n |
logFileStream.open(_logFileNames[logFileType], ios::app); |
|
logFileStream << System::getCurrentASCIITime() |
|
<< " " << tmp << (const char *)messageString.getCString() << endl; |
|
logFileStream.close(); |
|
} |
| |
const char* tmp = ""; |
static void setMaxLogFileSize(Uint32 maxLogFileSizeBytes) |
if (logLevel & Logger::TRACE) tmp = "TRACE "; |
{ |
if (logLevel & Logger::INFORMATION) tmp = "INFO "; |
_maxLogFileSizeBytes = maxLogFileSizeBytes; |
if (logLevel & Logger::WARNING) tmp = "WARNING "; |
} |
if (logLevel & Logger::SEVERE) tmp = "SEVERE "; |
private: |
if (logLevel & Logger::FATAL) tmp = "FATAL "; |
|
| |
_rep->logOf(logFileType) << System::getCurrentASCIITime() |
CString _logFileNames[int(Logger::NUM_LOGS)]; |
<< " " << tmp << (const char *)messageString.getCString() << endl; |
|
| |
|
static Uint32 _maxLogFileSizeBytes; |
|
# ifndef PEGASUS_OS_VMS |
|
CString _loggerLockFileName; |
|
Mutex _mutex; |
#endif | #endif |
|
}; |
|
|
|
Uint32 LoggerRep::_maxLogFileSizeBytes; |
|
|
|
#endif // !defined(PEGASUS_USE_SYSLOGS) |
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////// |
|
// |
|
// Logger |
|
// |
|
/////////////////////////////////////////////////////////////////////////////// |
|
|
|
void Logger::_putInternal( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
const Uint32 logComponent, // FUTURE: Support logComponent mask |
|
Uint32 logLevel, |
|
const String& message) |
|
{ |
|
if (!_rep) |
|
_rep = new LoggerRep(_homeDirectory); |
|
|
|
// Call the actual logging routine is in LoggerRep. |
|
_rep->log(logFileType, systemId, logLevel, message); |
|
|
|
// PEP 315 |
|
// The trace can be routed into the log. The logged trace messages are |
|
// logged with logFileType of Logger::TRACE_LOG. |
|
// To avoid a cirular writing of these messages, log messages with |
|
// logFileType of Logger::TRACE_LOG are never send to the trace. |
|
if (Logger::TRACE_LOG != logFileType) |
|
{ |
|
// For all other logFileType's send the log messages to the trace. |
|
// But do not write log messages to trace when the trace facility is |
|
// set to log. This avoids double messages. |
|
if (Tracer::TRACE_FACILITY_LOG != Tracer::getTraceFacility()) |
|
{ |
|
PEG_TRACE_CSTRING( |
|
TRC_LOGMSG, |
|
Tracer::LEVEL1, |
|
(const char*) message.getCString()); |
|
} |
} | } |
} | } |
| |
|
|
if (wouldLog(logLevel)) | if (wouldLog(logLevel)) |
{ | { |
Logger::_putInternal(logFileType, systemId, 0, logLevel, | Logger::_putInternal(logFileType, systemId, 0, logLevel, |
formatString, String::EMPTY, arg0, arg1, arg2, arg3, |
Formatter::format(formatString, arg0, arg1, arg2, arg3, |
arg4, arg5, arg6, arg7, arg8, arg9); |
arg4, arg5, arg6, arg7, arg8, arg9)); |
} | } |
} | } |
| |
|
|
{ | { |
if (wouldLog(logLevel)) | if (wouldLog(logLevel)) |
{ | { |
Logger::_putInternal(logFileType, systemId, 0, logLevel, |
Logger::_putInternal(logFileType, systemId, 0, logLevel, formatString); |
formatString, String::EMPTY); |
|
} | } |
} | } |
| |
|
|
if (wouldLog(logLevel)) | if (wouldLog(logLevel)) |
{ | { |
Logger::_putInternal(logFileType, systemId, 0, logLevel, | Logger::_putInternal(logFileType, systemId, 0, logLevel, |
formatString, String::EMPTY, arg0); |
Formatter::format(formatString, arg0)); |
} | } |
} | } |
| |
|
|
if (wouldLog(logLevel)) | if (wouldLog(logLevel)) |
{ | { |
Logger::_putInternal(logFileType, systemId, 0, logLevel, | Logger::_putInternal(logFileType, systemId, 0, logLevel, |
formatString, String::EMPTY, arg0, arg1); |
Formatter::format(formatString, arg0, arg1)); |
} | } |
} | } |
| |
|
|
if (wouldLog(logLevel)) | if (wouldLog(logLevel)) |
{ | { |
Logger::_putInternal(logFileType, systemId, 0, logLevel, | Logger::_putInternal(logFileType, systemId, 0, logLevel, |
formatString, String::EMPTY, arg0, arg1, arg2); |
Formatter::format(formatString, arg0, arg1, arg2)); |
} | } |
} | } |
| |
|
|
LogFileType logFileType, | LogFileType logFileType, |
const String& systemId, | const String& systemId, |
Uint32 logLevel, | Uint32 logLevel, |
const String& messageId, |
const MessageLoaderParms& msgParms) |
const String& formatString, |
|
const Formatter::Arg& arg0, |
|
const Formatter::Arg& arg1, |
|
const Formatter::Arg& arg2, |
|
const Formatter::Arg& arg3, |
|
const Formatter::Arg& arg4, |
|
const Formatter::Arg& arg5, |
|
const Formatter::Arg& arg6, |
|
const Formatter::Arg& arg7, |
|
const Formatter::Arg& arg8, |
|
const Formatter::Arg& arg9) |
|
{ |
|
if (wouldLog(logLevel)) |
|
{ |
|
Logger::_putInternal(logFileType, systemId, 0, logLevel, |
|
formatString, messageId, arg0, arg1, arg2, arg3, arg4, arg5, |
|
arg6, arg7, arg8, arg9); |
|
} |
|
} |
|
|
|
void Logger::put_l( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
Uint32 logLevel, |
|
const String& messageId, |
|
const String& formatString) |
|
{ |
|
if (wouldLog(logLevel)) |
|
{ |
|
Logger::_putInternal(logFileType, systemId, 0, logLevel, |
|
formatString, messageId); |
|
} |
|
} |
|
|
|
void Logger::put_l( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
Uint32 logLevel, |
|
const String& messageId, |
|
const String& formatString, |
|
const Formatter::Arg& arg0) |
|
{ | { |
if (wouldLog(logLevel)) | if (wouldLog(logLevel)) |
{ | { |
|
MessageLoaderParms parms = msgParms; |
|
parms.useProcessLocale = true; |
Logger::_putInternal(logFileType, systemId, 0, logLevel, | Logger::_putInternal(logFileType, systemId, 0, logLevel, |
formatString, messageId, arg0); |
MessageLoader::getMessage(parms)); |
} |
|
} |
|
|
|
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( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
const Uint32 logComponent, |
|
const String& formatString, |
|
const Formatter::Arg& arg0, |
|
const Formatter::Arg& arg1, |
|
const Formatter::Arg& arg2, |
|
const Formatter::Arg& arg3, |
|
const Formatter::Arg& arg4, |
|
const Formatter::Arg& arg5, |
|
const Formatter::Arg& arg6, |
|
const Formatter::Arg& arg7, |
|
const Formatter::Arg& arg8, |
|
const Formatter::Arg& arg9) |
|
{ |
|
if (wouldLog(Logger::TRACE)) |
|
{ |
|
Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE, |
|
formatString, String::EMPTY, arg0, arg1, arg2, arg3, arg4, arg5, |
|
arg6, arg7, arg8, arg9); |
|
} |
|
} |
|
|
|
void Logger::trace( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
const Uint32 logComponent, |
|
const String& formatString) |
|
{ |
|
if (wouldLog(Logger::TRACE)) |
|
{ |
|
Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE, |
|
formatString, String::EMPTY); |
|
} | } |
} | } |
| |
|
|
LogFileType logFileType, | LogFileType logFileType, |
const String& systemId, | const String& systemId, |
const Uint32 logComponent, | const Uint32 logComponent, |
const String& formatString, |
const String& message) |
const Formatter::Arg& arg0) |
|
{ | { |
if (wouldLog(Logger::TRACE)) | if (wouldLog(Logger::TRACE)) |
{ | { |
Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE, | Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE, |
formatString, String::EMPTY, arg0); |
message); |
} |
|
} |
|
|
|
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); |
|
} |
|
} |
|
|
|
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, |
|
const Formatter::Arg& arg3, |
|
const Formatter::Arg& arg4, |
|
const Formatter::Arg& arg5, |
|
const Formatter::Arg& arg6, |
|
const Formatter::Arg& arg7, |
|
const Formatter::Arg& arg8, |
|
const Formatter::Arg& arg9) |
|
{ |
|
if (wouldLog(Logger::TRACE)) |
|
{ |
|
Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE, |
|
formatString, messageId, arg0, arg1, arg2, arg3, arg4, arg5, arg6, |
|
arg7, arg8, arg9); |
|
} |
|
} |
|
|
|
void Logger::trace_l( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
const Uint32 logComponent, |
|
const String& messageId, |
|
const String& formatString) |
|
{ |
|
if (wouldLog(Logger::TRACE)) |
|
{ |
|
Logger::_putInternal(logFileType, systemId, logComponent, Logger::TRACE, |
|
formatString, messageId); |
|
} |
|
} |
|
|
|
void Logger::trace_l( |
|
LogFileType logFileType, |
|
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::setlogLevelMask( const String logLevelList ) | void Logger::setlogLevelMask( const String logLevelList ) |
{ | { |
Uint32 position = 0; |
|
Uint32 logLevelType = 0; | Uint32 logLevelType = 0; |
String logLevelName = logLevelList; | String logLevelName = logLevelList; |
| |
|
|
case Logger::FATAL: | case Logger::FATAL: |
_severityMask |= Logger::FATAL; | _severityMask |= Logger::FATAL; |
} | } |
|
|
|
Executor::updateLogLevel(logLevelName.getCString()); |
} | } |
else | else |
{ | { |
// Property logLevel not specified, set default value. | // Property logLevel not specified, set default value. |
_severityMask = ~Logger::TRACE; | _severityMask = ~Logger::TRACE; |
|
Executor::updateLogLevel("INFORMATION"); |
} | } |
return ; |
|
} | } |
| |
Boolean Logger::isValidlogLevel(const String logLevel) | Boolean Logger::isValidlogLevel(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 |
| |
Uint32 position=0; |
|
Uint32 index=0; | Uint32 index=0; |
String logLevelName = String::EMPTY; | String logLevelName = String::EMPTY; |
Boolean validlogLevel=false; | Boolean validlogLevel=false; |
Boolean retCode=true; |
|
| |
logLevelName = logLevel; | logLevelName = logLevel; |
| |
|
|
else | else |
{ | { |
// logLevels is empty, it is a valid value so return true | // logLevels is empty, it is a valid value so return true |
return _SUCCESS; |
return true; |
} | } |
| |
return validlogLevel; | return validlogLevel; |
} | } |
| |
|
#if !defined (PEGASUS_USE_SYSLOGS) |
|
void Logger::setMaxLogFileSize(Uint32 maxLogFileSizeBytes) |
|
{ |
|
LoggerRep::setMaxLogFileSize(maxLogFileSizeBytes); |
|
} |
|
#endif |
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |