version 1.23.2.1, 2006/02/10 16:09:37
|
version 1.38, 2008/12/01 17:49:52
|
|
|
//%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. |
// Permission is hereby granted, free of charge, to any person obtaining a |
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
// copy of this software and associated documentation files (the "Software"), |
// EMC Corporation; Symantec Corporation; The Open Group. |
// 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. |
|
// |
|
//============================================================================== |
|
// |
|
// Author: Mike Brasher (mbrasher@bmc.com) |
|
// |
|
// Modified By: Dave Rosckes (rosckes@us.ibm.com) |
|
// David Dillard, Symantec Corp. (david_dillard@symantec.com) |
|
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
#include <Pegasus/Common/System.h> | #include <Pegasus/Common/System.h> |
#include <Pegasus/Common/MessageLoader.h> | #include <Pegasus/Common/MessageLoader.h> |
| |
#define PEG_LOGGER_TRACE(ARGS_LIST) \ |
|
do \ |
|
{ \ |
|
if (Logger::wouldLog(Logger::TRACE)) \ |
|
{ \ |
|
Logger::trace ARGS_LIST ; \ |
|
} \ |
|
} \ |
|
while (0) |
|
|
|
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
class LoggerRep; | class LoggerRep; |
|
|
{ | { |
TRACE_LOG, | TRACE_LOG, |
STANDARD_LOG, | STANDARD_LOG, |
ERROR_LOG, |
AUDIT_LOG, // Use only if PEGASUS_ENABLE_AUDIT_LOGGER is defined |
DEBUG_LOG |
ERROR_LOG |
}; | }; |
| |
enum { NUM_LOGS = 4 }; | enum { NUM_LOGS = 4 }; |
|
|
@param Arg0 - Arg 9 - Up to 9 arguments representing the variables | @param Arg0 - Arg 9 - Up to 9 arguments representing the variables |
that go into the log entry. | that go into the log entry. |
<pre> | <pre> |
Logger::put(Logger::TRACE_LOG, "CIMServer", Logger::WARNING, |
Logger::put(Logger::TRACE_LOG, System::CIMSERVER, Logger::WARNING, |
"X=$0, Y=$1, Z=$2", 88, "Hello World", 7.5); | "X=$0, Y=$1, Z=$2", 88, "Hello World", 7.5); |
</pre> | </pre> |
*/ | */ |
|
|
@param systemId - ID of the system generating the log entry within | @param systemId - ID of the system generating the log entry within |
Pegasus. This is user defined but generally breaks down into major | Pegasus. This is user defined but generally breaks down into major |
Pegasus components. | Pegasus components. |
@param level logLevel of the log entry. To be used both t0 |
@param level logLevel of the log entry. To be used both to |
mark the log entry and tested against a mask to determine if log | mark the log entry and tested against a mask to determine if log |
entry should be written. | entry should be written. |
@param messageId Message ID of the format string to load from |
@param msgParms MessageLoaderParms object containing the localizable |
the resource bundle. |
message to log. |
@param formatString Default format definition string. See the |
|
Formatter for details. This will be used as the default format string |
|
in case the resource bundle cannot be found. |
|
@param Arg0 - Arg 9 - Up to 9 arguments representing the variables |
|
that go into the log entry. |
|
<pre> |
|
Logger::put(Logger::TRACE_LOG, "CIMServer", Logger::WARNING, |
|
"X=$0, Y=$1, Z=$2", 88, "Hello World", 7.5); |
|
</pre> |
|
*/ |
|
static void 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, |
|
const Formatter::Arg& arg3, |
|
const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG); |
|
|
|
/** Optimized zero-argument form of put_l(). |
|
*/ |
|
static void put_l( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
Uint32 logLevel, |
|
const String& messageId, |
|
const String& formatString); |
|
|
|
/** Optimized one-argument form of put_l(). |
|
*/ |
|
static void put_l( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
Uint32 logLevel, |
|
const String& messageId, |
|
const String& formatString, |
|
const Formatter::Arg& arg0); |
|
|
|
/** Optimized two-argument form of put_l(). |
|
*/ |
|
static void put_l( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
Uint32 logLevel, |
|
const String& messageId, |
|
const String& formatString, |
|
const Formatter::Arg& arg0, |
|
const Formatter::Arg& arg1); |
|
|
|
/** Optimized three-argument form of put_l(). |
|
*/ | */ |
static void put_l( | static void put_l( |
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); |
|
|
|
/** Puts a message to the define log. Should only be used for trace type |
|
logs. |
|
*/ |
|
static void 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 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG); |
|
| |
/** Optimized three-argument form of trace(). |
/** Puts a trace message into the specified log. |
*/ | */ |
static void trace( | static void trace( |
LogFileType logFileType, | LogFileType logFileType, |
const String& systemId, | const String& systemId, |
const Uint32 logComponent, | const Uint32 logComponent, |
const String& formatString); |
const String& message); |
|
|
/** Optimized one-argument form of trace(). |
|
*/ |
|
static void trace( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
const Uint32 logComponent, |
|
const String& formatString, |
|
const Formatter::Arg& arg0); |
|
|
|
/** Optimized two-argument form of trace(). |
|
*/ |
|
static void trace( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
const Uint32 logComponent, |
|
const String& formatString, |
|
const Formatter::Arg& arg0, |
|
const Formatter::Arg& arg1); |
|
|
|
/** Optimized three-argument form of trace(). |
|
*/ |
|
static void trace( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
const Uint32 logComponent, |
|
const String& formatString, |
|
const Formatter::Arg& arg0, |
|
const Formatter::Arg& arg1, |
|
const Formatter::Arg& arg2); |
|
|
|
/** Puts a localized message to the log. Should only be used |
|
for trace type logs. |
|
*/ |
|
static void 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 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG); |
|
|
|
/** Optimized zero-argument form of trace_l(). |
|
*/ |
|
static void trace_l( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
const Uint32 logComponent, |
|
const String& messageId, |
|
const String& formatString); |
|
|
|
/** Optimized one-argument form of trace_l(). |
|
*/ |
|
static void trace_l( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
const Uint32 logComponent, |
|
const String& messageId, |
|
const String& formatString, |
|
const Formatter::Arg& arg0); |
|
|
|
/** Optimized two-argument form of trace_l(). |
|
*/ |
|
static void trace_l( |
|
LogFileType logFileType, |
|
const String& systemId, |
|
const Uint32 logComponent, |
|
const String& messageId, |
|
const String& formatString, |
|
const Formatter::Arg& arg0, |
|
const Formatter::Arg& arg1); |
|
|
|
/** Optimized three-argument form of trace_l(). |
|
*/ |
|
static void 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); |
|
| |
/** setHomeDirectory | /** setHomeDirectory |
*/ | */ |
|
|
*/ | */ |
static void setlogLevelMask(const String logLevelList); | static void setlogLevelMask(const String logLevelList); |
| |
/** setLogWriteControlMask |
|
*/ |
|
static void setLogWriteControlMask(const Uint32); |
|
|
|
/** Returns true if the given string is one of the legal log levels. | /** Returns true if the given string is one of the legal log levels. |
*/ | */ |
static Boolean isValidlogLevel(const String logLevel); | static Boolean isValidlogLevel(const String logLevel); |
|
|
return (_severityMask & logLevel) != 0; | return (_severityMask & logLevel) != 0; |
} | } |
| |
|
#if !defined(PEGASUS_USE_SYSLOGS) |
|
static void setMaxLogFileSize (Uint32 maxLogFileSizeBytes); |
|
#endif |
|
|
private: | private: |
| |
static LoggerRep* _rep; | static LoggerRep* _rep; |
static String _homeDirectory; | static String _homeDirectory; |
static Uint32 _severityMask; | static Uint32 _severityMask; |
static Uint32 _writeControlMask; |
|
|
|
static const char _SEPARATOR; |
|
static const Uint32 _NUM_LOGLEVEL; | static const Uint32 _NUM_LOGLEVEL; |
| |
static const Boolean _SUCCESS; |
|
static const Boolean _FAILURE; |
|
|
|
static void _putInternal( | static void _putInternal( |
LogFileType logFileType, | LogFileType logFileType, |
const String& systemId, | const String& systemId, |
const Uint32 logComponent, | const Uint32 logComponent, |
Uint32 logLevel, | Uint32 logLevel, |
const String& formatString, |
const String& message); |
const String& messageId, |
|
const Formatter::Arg& arg0 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg1 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg2 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg3 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG, |
|
const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG); |
|
}; | }; |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |