From d64d1bc5c030df7eaa5332698bcbb228c8164e72 Mon Sep 17 00:00:00 2001 From: ahodgkinson Date: Tue, 6 Jun 2006 22:49:49 +0000 Subject: [PATCH] Various message logging and async I/O changes. git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@528 0109f412-320b-0410-ab79-c3e0c5ffbbe6 --- flaim/src/fdb.cpp | 24 +- flaim/src/flaim.h | 184 +------ flaim/src/flaimsys.h | 3 +- flaim/src/flcreate.cpp | 12 +- flaim/src/flog.cpp | 1179 ---------------------------------------- flaim/src/flog.h | 84 --- flaim/src/flopen.cpp | 2 +- flaim/src/fqcur.cpp | 19 +- flaim/src/fqlog.cpp | 169 +++--- flaim/src/fquery.h | 6 +- flaim/src/fslfileu.cpp | 2 +- flaim/src/fstructs.h | 2 +- flaim/src/fsysdata.cpp | 12 +- flaim/src/imonfsys.cpp | 13 - flaim/src/scache.cpp | 4 +- 15 files changed, 126 insertions(+), 1589 deletions(-) delete mode 100644 flaim/src/flog.cpp delete mode 100644 flaim/src/flog.h diff --git a/flaim/src/fdb.cpp b/flaim/src/fdb.cpp index 1ffe1bd..cecec58 100644 --- a/flaim/src/fdb.cpp +++ b/flaim/src/fdb.cpp @@ -466,7 +466,7 @@ void flmLogError( FLMINT iLineNumber) { flmLogMessage( - FLM_DEBUG_MESSAGE, + F_DEBUG_MESSAGE, FLM_YELLOW, FLM_BLACK, pszFileName @@ -481,18 +481,24 @@ void flmLogError( Desc: Logs messages ****************************************************************************/ void flmLogMessage( - FlmLogMessageSeverity eMsgSeverity, + eLogMessageSeverity eMsgSeverity, eColorType foreground, eColorType background, const char * pszFormat, ...) { - FLMINT iLen; - f_va_list args; - F_LogMessage * pLogMsg = NULL; - char * pszMsgBuf = NULL; + FLMINT iLen; + f_va_list args; + IF_LogMessageClient * pLogMsg = NULL; + char * pszMsgBuf = NULL; - if( (pLogMsg = flmBeginLogMessage( FLM_GENERAL_MESSAGE, eMsgSeverity)) != NULL) + if( !gv_FlmSysData.pLogger) + { + return; + } + + if( (pLogMsg = gv_FlmSysData.pLogger->beginMessage( + FLM_GENERAL_MESSAGE, eMsgSeverity)) != NULL) { if( RC_OK( f_alloc( 1024, &pszMsgBuf))) { @@ -504,7 +510,7 @@ void flmLogMessage( pLogMsg->appendString( pszMsgBuf); } - flmEndLogMessage( &pLogMsg); + f_endLogMessage( &pLogMsg); if( pszMsgBuf) { @@ -524,7 +530,7 @@ FSTATIC void flmLogMustCloseReason( // Log a message indicating why the "must close" flag was set flmLogMessage( - FLM_DEBUG_MESSAGE, + F_DEBUG_MESSAGE, FLM_YELLOW, FLM_BLACK, "Database (%s) must be closed because of a 0x%04X error, File=%s, Line=%d.", diff --git a/flaim/src/flaim.h b/flaim/src/flaim.h index 392f2c0..38cf3f6 100644 --- a/flaim/src/flaim.h +++ b/flaim/src/flaim.h @@ -382,7 +382,6 @@ class FlmRecord; class FlmRecordSet; - class F_LogMessage; class F_Restore; /*************************************************************************** @@ -1726,7 +1725,7 @@ FLM_CLOSE_FILE, /// FlmConfig().\ Set the logger object.\ \n - /// Input: pvValue1 is (F_Logger *), pointer to logger object.\ \n + /// Input: pvValue1 is (IF_LoggerClient *), pointer to logger object.\ \n /// NULL means disable logging. FLM_LOGGER, @@ -3207,187 +3206,6 @@ FLM_NUM_MESSAGE_TYPES } FlmLogMessageType; - /// Message severity. - typedef enum - { - FLM_FATAL_MESSAGE = 0, ///< Indicates that a fatal error occurred - the kind that would normally - ///< require a shutdown or other corrective action by an administrator. - FLM_WARN_MESSAGE, ///< Warning message. - FLM_ERR_MESSAGE, ///< Non-fatal error message. - FLM_INFO_MESSAGE, ///< Information-only message. - FLM_DEBUG_MESSAGE ///< Debug message. - } FlmLogMessageSeverity; - - /// This is an abstract base class that allows an application to catch messages logged by FLAIM. The - /// application must create an implementation for this class and then pass that object into - /// the FlmConfig() function using the eFlmConfigTypes::FLM_LOGGER option. Doing so allows the - /// application to catch messages logged by FLAIM. The application can do whatever it wants with - /// the messages - write them to a log file, display them to a console, save them to a database, etc. - class FLMEXP F_Logger : public F_Object - { - public: - - F_Logger(); - - virtual ~F_Logger(); - - // Pure virtual functions that must be implemented - - /// FLAIM calls this method to start a new message. The application should return to FLAIM - /// an ::F_LogMessage object that FLAIM can then use to format a message. - virtual F_LogMessage * beginMessage( - FlmLogMessageType eMsgType, ///< Type of message FLAIM wants to log.\ If the application - ///< has disabled messages of this type, it should return - ///< a NULL from the function.\ An application can determine - ///< if a particular message type has been disabled by calling - ///< the F_Logger::messageTypeEnabled() method. - FlmLogMessageSeverity eMsgSeverity ///< Message severity of the message FLAIM wants to - ///< log. - ) = 0; - - // Functions implemented in the base class - - /// This method is provided by FLAIM to allow an application to enable logging of a particular - /// message type. This method should be called once for each type of message the application - /// wants to enable. - void enableMessageType( - FlmLogMessageType eMsgType ///< Type of message to be enabled. - ); - - /// This method is provided by FLAIM to allow an applicatoin to enable logging of all - /// message types. - void enableAllMessageTypes( void); - - /// This method is provided by FLAIM to allow an application to disable logging of a particular - /// message type. This method should be called once for each type of message the application - /// wants to disable. - void disableMessageType( - FlmLogMessageType eMsgType); - - /// This method is provided by FLAIM to allow an applicatoin to disable logging of all - /// message types. - void disableAllMessageTypes( void); - - /// This method is provided by FLAIM to allow an application to determine if logging has - /// been enabled for a particular message type. An application would typically call this - /// method from within its implementation of the F_Logger::beginMessage() method - /// to determine if it should return an ::F_LogMessage object to FLAIM. - FLMBOOL messageTypeEnabled( - FlmLogMessageType eMsgType ///< Type of message the application wants to determine if - ///< message logging is enabled for. - ); - - /// Lock the ::F_Logger object. This method and the F_Logger::unlockLogger() method are used internally - /// by FLAIM to control multi-thread access to the logger object. This method was - /// made public in case the application also wants to control multi-thread access. - void lockLogger( void); - - /// Unlock the ::F_Logger object. This method and the F_Logger::lockLogger() method are used internally - /// by FLAIM to control multi-thread access to the logger object. This method was - /// made public in case the application also wants to control multi-thread access. - void unlockLogger( void); - - /// Setup the ::F_Logger object. The application must call this method before doing anything else with - /// the object. - RCODE setupLogger( void); - - /// Determine if the ::F_Logger object has been properly setup - that is, has the F_Logger::setupLogger() - /// method been called. - FLMBOOL loggerIsSetup( void); - - private: - - F_MUTEX m_hMutex; - FLMBOOL m_bSetupCalled; - FLMBOOL * m_pbEnabledList; - }; - - /// This is an abstract base class that allows an application to catch messages logged by FLAIM. The - /// application must create an implementation for this class and then return an object of that - /// class when the F_Logger::beginMessage() method is called by FLAIM. Doing so allows the - /// application to catch messages logged by FLAIM. The application can do whatever it wants with - /// the messages - write them to a log file, display them to a console, save them to a database, etc. - - class FLMEXP F_LogMessage : public F_Object - { - public: - - F_LogMessage() - { - m_uiBackColors = 0; - m_uiForeColors = 0; - m_currentForeColor = FLM_LIGHTGRAY; - m_currentBackColor = FLM_BLACK; - } - - virtual ~F_LogMessage() - { - } - - // Pure virtual functions - - /// Set the current foreground and background colors for the message. FLAIM calls this to - /// set the colors for text that is appended after this call (see F_LogMessage::appendString()). - /// The colors may be changed at any time - thus allowing a message to have multiple different colors. - virtual void changeColor( - eColorType foreColor, ///< Foreground color. - eColorType backColor ///< Background color. - ) = 0; - - /// Append a string to the message. FLAIM calls this to add text to a message. It may be called - /// multiple times by FLAIM to format a complete message. The message is not complete until - /// FLAIM calls the F_LogMessage::endMessage() method. - virtual void appendString( - const char * pszStr ///< Text to append to the message. - ) = 0; - - /// Append a newline to the message. FLAIM calls this when it wants to create a multi-line - /// message. Rather than embedding a newline character, FLAIM calls this method. This - /// allows an application to recognize the fact that there are multiple lines in the message - /// and to log, display, store, etc. (whatever) them accordingly. - virtual void newline( void) = 0; - - /// End the current message. FLAIM calls this to end the current message. The application - /// should finish logging, displaying, storing, etc. (whatever) the message. The object - /// should be reset in case FLAIM wants to start logging a new message. - virtual void endMessage( void) = 0; - - // Public methods. The following methods are only be called by FLAIM internally. They are - // all implemented by FLAIM. - - void pushForegroundColor( void); - - void popForegroundColor( void); - - void pushBackgroundColor( void); - - void popBackgroundColor( void); - - eColorType getForegroundColor() - { - return( m_currentForeColor); - } - - eColorType getBackgroundColor() - { - return( m_currentBackColor); - } - - void setColor( - eColorType foreColor, - eColorType backColor); - - private: - - #define F_MAX_COLOR_STACK_SIZE 8 - eColorType m_backColors[ F_MAX_COLOR_STACK_SIZE]; - eColorType m_foreColors[ F_MAX_COLOR_STACK_SIZE]; - FLMUINT m_uiBackColors; - FLMUINT m_uiForeColors; - eColorType m_currentBackColor; - eColorType m_currentForeColor; - }; - #define F_MAX_NUM_BUF 12 /// Convert a FLMUINT value to FLAIM's internal storage format for numbers. diff --git a/flaim/src/flaimsys.h b/flaim/src/flaimsys.h index c0d6a4b..78b3776 100644 --- a/flaim/src/flaimsys.h +++ b/flaim/src/flaimsys.h @@ -67,7 +67,6 @@ class F_CCS; #include "filesys.h" #include "fquery.h" #include "fscursor.h" -#include "flog.h" #include "flmimon.h" #include "flmstat.h" #include "fcs.h" @@ -943,7 +942,7 @@ void flmLogError( FLMINT iLineNumber = 0); void flmLogMessage( - FlmLogMessageSeverity eMsgSeverity, + eLogMessageSeverity eMsgSeverity, eColorType eForground, eColorType eBackground, const char * pszFormat, diff --git a/flaim/src/flcreate.cpp b/flaim/src/flcreate.cpp index 4cf93b1..8ef31f8 100644 --- a/flaim/src/flcreate.cpp +++ b/flaim/src/flcreate.cpp @@ -372,12 +372,12 @@ FSTATIC RCODE flmInitNewFile( // Initialize the database file header. - // Allocate a buffer to use - must be AT LEAST 2K. - uiBufSize = (FLMUINT)((uiBlkSize < 2048) ? (FLMUINT)2048 : (FLMUINT)uiBlkSize); - if (RC_BAD( rc = f_calloc( uiBufSize, &pBuf))) + + if( RC_BAD( rc = f_allocAlignedBuffer( uiBufSize, + (void **)&pBuf))) { goto Exit; } @@ -388,10 +388,6 @@ FSTATIC RCODE flmInitNewFile( goto Exit; } - // Free the buffer before returning. - - f_free( &pBuf); - // Allocate the pRfl object. Could not do this until this point // because we need to have the version number, block size, etc. // setup in the pFile->FileHdr. @@ -438,7 +434,7 @@ Exit: if (pBuf) { - f_free( &pBuf); + f_freeAlignedBuffer( (void **)&pBuf); } if (bTransStarted) diff --git a/flaim/src/flog.cpp b/flaim/src/flog.cpp deleted file mode 100644 index 656777d..0000000 --- a/flaim/src/flog.cpp +++ /dev/null @@ -1,1179 +0,0 @@ -//------------------------------------------------------------------------- -// Desc: Message logging. -// Tabs: 3 -// -// Copyright (c) 2001-2003,2005-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: flog.cpp 12331 2006-01-23 10:19:55 -0700 (Mon, 23 Jan 2006) ahodgkinson $ -//------------------------------------------------------------------------- - -#include "flaimsys.h" - -FSTATIC void flmLogProcessFieldInfo( - const char ** ppszFormat, - FLMUINT * puiWidth, - FLMUINT * puiPrecision, - FLMUINT * puiFlags, - f_va_list * args); - -FSTATIC RCODE flmLogProcessFormatString( - FLMUINT uiLen, - F_LogMessage * pLogMessage, ...); - -FSTATIC RCODE flmLogParsePrintfArgs( - const char * pszFormat, - f_va_list * args, - F_LogMessage * pLogMessage); - -FSTATIC RCODE flmLogStringFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - F_LogMessage * pLogMessage, - f_va_list * args); - -FSTATIC FLMUINT flmLogPrintNumber( - FLMUINT uiNumber, - FLMUINT uiBase, - char * pszBuffer); - -FSTATIC RCODE flmLogNumberFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - F_LogMessage * pLogMessage, - f_va_list * args); - -FSTATIC RCODE flmLogErrorFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - F_LogMessage * pLogMessage, - f_va_list * args); - -FSTATIC RCODE flmLogColorFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - F_LogMessage * pLogMessage, - f_va_list * args); - -FSTATIC RCODE flmLogCharFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - F_LogMessage * pLogMessage, - f_va_list * args); - -FSTATIC RCODE flmLogNotHandledFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - F_LogMessage * pLogMessage, - f_va_list * args); - -// Percent formating prefixes - -#define P_NONE 0 -#define P_MINUS 1 -#define P_PLUS 2 -#define P_POUND 3 - -// Width and precision flags - -#define MINUS_FLAG 0x0001 -#define PLUS_FLAG 0x0002 -#define SPACE_FLAG 0x0004 -#define POUND_FLAG 0x0008 -#define ZERO_FLAG 0x0010 -#define SHORT_FLAG 0x0020 -#define LONG_FLAG 0x0040 -#define DOUBLE_FLAG 0x0080 - -// Format handlers - -typedef RCODE (*FORMATHANDLER)( - FLMBYTE ucFormatChar, - FLMUINT uiWdth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - F_LogMessage * pLogMessage, - f_va_list * args); - -typedef struct FORMATTERTABLE -{ - FORMATHANDLER formatTextHandler; - FORMATHANDLER percentHandler; - FORMATHANDLER lowerCaseHandlers[ 26]; - FORMATHANDLER upperCaseHandlers[ 26]; -} FORMATTERTABLE; - -/**************************************************************************** -Desc: Default formatter table -****************************************************************************/ -FSTATIC FORMATTERTABLE flmLogFormatHandlers = -{ - flmLogStringFormatter, - flmLogCharFormatter, - { - /* a */ flmLogNotHandledFormatter, - /* b */ flmLogNotHandledFormatter, - /* c */ flmLogCharFormatter, - /* d */ flmLogNumberFormatter, - /* e */ flmLogErrorFormatter, - /* f */ flmLogNotHandledFormatter, - /* g */ flmLogNotHandledFormatter, - /* h */ flmLogNotHandledFormatter, - /* i */ flmLogNotHandledFormatter, - /* j */ flmLogNotHandledFormatter, - /* k */ flmLogNotHandledFormatter, - /* l */ flmLogNotHandledFormatter, - /* m */ flmLogNotHandledFormatter, - /* n */ flmLogNotHandledFormatter, - /* o */ flmLogNumberFormatter, - /* p */ flmLogNotHandledFormatter, - /* q */ flmLogNotHandledFormatter, - /* r */ flmLogNotHandledFormatter, - /* s */ flmLogStringFormatter, - /* t */ flmLogNotHandledFormatter, - /* u */ flmLogNumberFormatter, - /* v */ flmLogNotHandledFormatter, - /* w */ flmLogNotHandledFormatter, - /* x */ flmLogNumberFormatter, - /* y */ flmLogNotHandledFormatter, - /* z */ flmLogNotHandledFormatter, - }, - { - /* A */ flmLogNotHandledFormatter, - /* B */ flmLogNotHandledFormatter, - /* C */ flmLogColorFormatter, - /* D */ flmLogNotHandledFormatter, - /* E */ flmLogErrorFormatter, - /* F */ flmLogNotHandledFormatter, - /* G */ flmLogNotHandledFormatter, - /* H */ flmLogNotHandledFormatter, - /* I */ flmLogNotHandledFormatter, - /* J */ flmLogNotHandledFormatter, - /* K */ flmLogNotHandledFormatter, - /* L */ flmLogNotHandledFormatter, - /* M */ flmLogNotHandledFormatter, - /* N */ flmLogNotHandledFormatter, - /* O */ flmLogNotHandledFormatter, - /* P */ flmLogNotHandledFormatter, - /* Q */ flmLogNotHandledFormatter, - /* R */ flmLogNotHandledFormatter, - /* S */ flmLogStringFormatter, - /* T */ flmLogNotHandledFormatter, - /* U */ flmLogNotHandledFormatter, - /* V */ flmLogNotHandledFormatter, - /* W */ flmLogNotHandledFormatter, - /* X */ flmLogNumberFormatter, - /* Y */ flmLogNotHandledFormatter, - /* Z */ flmLogNotHandledFormatter, - } -}; - -/**************************************************************************** -Desc: *ppszFormat points to text following a '%' sign. Process legal field - information. Leave *ppszFormat pointing at the format specifier char. -****************************************************************************/ -FSTATIC void flmLogProcessFieldInfo( - const char ** ppszFormat, - FLMUINT * puiWidth, - FLMUINT * puiPrecision, - FLMUINT * puiFlags, - f_va_list * args) -{ - const char * pszTmp = *ppszFormat; - - /* process flags */ - *puiFlags = 0; - - while( *pszTmp == '-' || *pszTmp == '+' || *pszTmp == ' ' || - *pszTmp == '#' || *pszTmp == '0') - { - switch( *pszTmp) - { - case '-': - *puiFlags |= MINUS_FLAG; - break; - case '+': - *puiFlags |= PLUS_FLAG; - break; - case ' ': - *puiFlags |= SPACE_FLAG; - break; - case '#': - *puiFlags |= POUND_FLAG; - break; - case '0': - *puiFlags |= ZERO_FLAG; - break; - } - pszTmp++; - } - - /* process width */ - - *puiWidth = 0; - if( *pszTmp == '*') - { - *puiWidth = f_va_arg( *args, unsigned int); - pszTmp++; - } - else while( *pszTmp >= '0' && *pszTmp <= '9') - { - *puiWidth = (*puiWidth * 10) + (*pszTmp - '0'); - pszTmp++; - } - - /* process precision */ - - *puiPrecision = 0; - if( *pszTmp == '.') - { - pszTmp++; - if( *pszTmp == '*') - { - *puiPrecision = f_va_arg( *args, unsigned int); - pszTmp++; - } - else while( *pszTmp >= '0' && *pszTmp <= '9') - { - *puiPrecision = (*puiPrecision * 10) + (*pszTmp - '0'); - pszTmp++; - } - } - - /* size modifiers */ - - switch( *pszTmp) - { - case 'L': - *puiFlags |= DOUBLE_FLAG; - pszTmp++; - break; - case 'l': - *puiFlags |= LONG_FLAG; - pszTmp++; - break; - case 'h': - *puiFlags |= SHORT_FLAG; - pszTmp++; - break; - } - - *ppszFormat = pszTmp; -} - -/**************************************************************************** -Desc: Handle text portions of the format string -****************************************************************************/ -FSTATIC RCODE flmLogProcessFormatString( - FLMUINT uiLen, - F_LogMessage * pLogMessage, ...) -{ - RCODE rc = FERR_OK; - f_va_list args; - - f_va_start( args, pLogMessage); - if( uiLen && flmLogFormatHandlers.formatTextHandler) - { - rc = flmLogFormatHandlers.formatTextHandler( - 0, uiLen, uiLen, 0, pLogMessage, (f_va_list *)&args); - } - f_va_end(args); - - return( rc); -} - -/**************************************************************************** -Desc: Parse arguments in format string, calling appropriate handlers -****************************************************************************/ -FSTATIC RCODE flmLogParsePrintfArgs( - const char * pszFormat, - f_va_list * args, - F_LogMessage * pLogMessage) -{ - RCODE rc = FERR_OK; - FLMBYTE ucChar; - FLMUINT uiFlags; - FLMUINT uiWidth; - FLMUINT uiPrecision; - const char * pszTextStart = pszFormat; - FORMATHANDLER fnHandler; - - while( (ucChar = *pszFormat++) != 0) - { - if( ucChar != '%') - { - // Handle invalid characters - if( ucChar < ASCII_SPACE || ucChar > ASCII_TILDE) - { - uiWidth = (FLMUINT)(pszFormat - pszTextStart - 1); - - if( uiWidth) - { - if( RC_BAD( rc = flmLogProcessFormatString( uiWidth, - pLogMessage, pszTextStart))) - { - goto Exit; - } - } - - // Only call newline() if ASCII_NEWLINE character. - // We will skip ASCII_CR characters - - if( ucChar == ASCII_NEWLINE) - { - pLogMessage->newline(); - } - pszTextStart = pszFormat; - } - - continue; - } - - uiWidth = (FLMUINT)(pszFormat - pszTextStart - 1); - if( RC_BAD( rc = flmLogProcessFormatString( uiWidth, - pLogMessage, pszTextStart))) - { - goto Exit; - } - - flmLogProcessFieldInfo( &pszFormat, &uiWidth, - &uiPrecision, &uiFlags, args); - - if( (ucChar = *pszFormat++) >= 'a' && ucChar <= 'z') - { - fnHandler = flmLogFormatHandlers.lowerCaseHandlers[ ucChar - 'a']; - } - else if( ucChar >= 'A' && ucChar <= 'Z') - { - fnHandler = flmLogFormatHandlers.upperCaseHandlers[ ucChar - 'A']; - } - else if( ucChar == '%') - { - fnHandler = flmLogFormatHandlers.percentHandler; - } - else - { - fnHandler = flmLogNotHandledFormatter; - } - - if( RC_BAD( rc = fnHandler( ucChar, uiWidth, - uiPrecision, uiFlags, pLogMessage, args))) - { - goto Exit; - } - pszTextStart = pszFormat; - } - - if( RC_BAD( rc = flmLogProcessFormatString( - (FLMUINT)(pszFormat - pszTextStart - 1), - pLogMessage, pszTextStart))) - { - goto Exit; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Default string formatter. - Prints the ascii string specified by ADDRESS in 's'. - Prints length preceeded string specified by ADDRESS in 'S'. - Prints unicode string specified by ADDRESS in 'U'. - Format: %[flags][width][.prec]'s'|'S'|'U' - flags = '-' left justifies if string length < width - width = minimum number of characters to print - prec = maximum number of characters to print -****************************************************************************/ -FSTATIC RCODE flmLogStringFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - F_LogMessage * pLogMessage, - f_va_list * args) -{ - RCODE rc = FERR_OK; - const char * pszNullPointerStr = ""; - FLMUINT uiLength; - FLMUINT uiCount; - char szOutputBuf[ 128]; - char * pszDest = &szOutputBuf[ 0]; - FLMUINT uiMaxLen = sizeof( szOutputBuf) - 1; - const char * pszString = f_va_arg( *args, char *); - void * pAllocBuf = NULL; - - if( uiWidth >= uiMaxLen) - { - // Need to allocate a temporary buffer - - uiMaxLen = uiWidth; - if( RC_BAD( rc = f_alloc( (FLMUINT)(uiMaxLen + 1), &pAllocBuf))) - { - goto Exit; - } - - pszDest = (char *)pAllocBuf; - } - - if( !pszString) - { - uiLength = f_strlen( pszNullPointerStr); - } - else if( ucFormatChar == 'S') - { - uiLength = (FLMUINT)(*pszString); - pszString++; - } - else - { - uiLength = ucFormatChar == 0 ? uiWidth : f_strlen( pszString); - } - - if( uiPrecision > 0 && uiLength > uiPrecision) - { - uiLength = uiPrecision; - } - uiCount = uiWidth - uiLength; - - if( uiLength < uiWidth && !(uiFlags & MINUS_FLAG)) - { - // right justify - f_memset( pszDest, ' ', uiCount); - pszDest += uiCount; - } - - if( !pszString) - { - f_memcpy( pszDest, pszNullPointerStr, uiLength); - } - else - { - f_memcpy( pszDest, pszString, uiLength); - } - - pszDest += uiLength; - - // left justify - - if( uiLength < uiWidth && (uiFlags & MINUS_FLAG)) - { - f_memset( pszDest, ' ', uiCount); - pszDest += uiCount; - } - - *pszDest = 0; - pLogMessage->appendString( szOutputBuf); - -Exit: - - if( pAllocBuf) - { - f_free( &pAllocBuf); - } - - return( rc); -} - -/**************************************************************************** -Desc: This is used by printf to output numbers. It uses recursion to - separate the numbers down to individual digits and then calls - PrintDigit to output each digit. -****************************************************************************/ -FSTATIC FLMUINT flmLogPrintNumber( - FLMUINT uiNumber, - FLMUINT uiBase, - char * pszBuffer) -{ - FLMBYTE ucChar = (FLMBYTE)( uiNumber % uiBase); - FLMUINT uiIndex = uiNumber / uiBase; - - uiIndex = uiIndex ? flmLogPrintNumber( uiIndex, uiBase, pszBuffer) : 0; - pszBuffer[ uiIndex] = (FLMBYTE)(ucChar > 9 - ? ucChar + 'a' - 10 - : ucChar + '0'); - - return( uiIndex + 1); -} - -/**************************************************************************** -Desc: Default number formatter. - Prints the number specified by VALUE in 'd', 'o', 'u', 'x', or 'X' - Format: %[flags][width][.prec]'E' - flags = 'h' value is uint16 - 'l' value is uint32 - '-' left align result - '+' print plus sign if positive - '#' print '0x' in front of hex numbers - '0' zero-fill - width = minimum number of characters to print - prec = maximum number of characters to print (truncates or rounds) -****************************************************************************/ -FSTATIC RCODE flmLogNumberFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - F_LogMessage * pLogMessage, - f_va_list * args) -{ - FLMUINT uiPrefix = P_NONE; - FLMUINT uiLength; - FLMUINT uiBase = 10; - FLMUINT uiLoop; - char szNumberBuf[ 32]; - char szOutputBuf[ 128]; - char * pszDest = &szOutputBuf[ 0]; - FLMUINT uiMaxLen = sizeof( szOutputBuf) - 1; - char * pszTmp; - FLMUINT uiArg; - - if( uiFlags & SHORT_FLAG) - { - uiArg = (FLMUINT)f_va_arg( *args, int); - } - else if( uiFlags & LONG_FLAG) - { - uiArg = (FLMUINT)f_va_arg( *args, long int); - } - else - { - uiArg = (FLMUINT)f_va_arg( *args, int); - } - - switch( ucFormatChar) - { - case 'd': - if( (long)uiArg < 0) - { - // handle negatives - uiPrefix = P_MINUS; - if( uiWidth > 0) - { - uiWidth--; - } - uiArg = (FLMUINT)(-((long)uiArg)); - } - else if( uiFlags & PLUS_FLAG) - { - uiPrefix = P_PLUS; - if( uiWidth > 0) - { - uiWidth--; - } - } - break; - - case 'o': - uiBase = 8; - break; - - case 'x': - case 'X': - if( (uiFlags & POUND_FLAG) != 0 && uiArg) - { - uiPrefix = P_POUND; - if( uiWidth > 1) - { - uiWidth -= 2; - } - } - uiBase = 16; - break; - } - - uiLength = flmLogPrintNumber( uiArg, uiBase, szNumberBuf); - szNumberBuf[ uiLength] = 0; - - if( ucFormatChar == 'X') - { - pszTmp = &szNumberBuf[ 0]; - while( *pszTmp) - { - if( (*pszTmp >= 'a') && (*pszTmp <= 'z')) - { - *pszTmp = (FLMBYTE)((*pszTmp - 'a') + 'A'); - } - pszTmp++; - } - } - - if( uiWidth < uiLength) - { - uiWidth = uiLength; - } - - if( uiFlags & ZERO_FLAG) - { - // zero fill - uiPrecision = uiWidth; - } - else if( !(uiFlags & MINUS_FLAG)) - { - // right justify - while( uiWidth > uiLength && uiWidth > uiPrecision && uiMaxLen > 0) - { - *pszDest++ = ' '; - uiMaxLen--; - uiWidth--; - } - } - - // handle the prefix if any - - if( uiMaxLen) - { - switch( uiPrefix) - { - case P_MINUS: - *pszDest++ = '-'; - uiMaxLen--; - break; - case P_PLUS: - *pszDest++ = '+'; - uiMaxLen--; - break; - case P_POUND: - *pszDest++ = '0'; - uiMaxLen--; - *pszDest++ = ucFormatChar; - uiMaxLen--; - break; - } - } - - // handle the precision - while( uiLength < uiPrecision && uiMaxLen) - { - *pszDest++ = '0'; - uiMaxLen--; - uiPrecision--; - uiWidth--; - } - - // print the number - for( uiLoop = uiLength, pszTmp = &szNumberBuf[ 0]; - uiLoop > 0 && uiMaxLen; uiLoop--, uiMaxLen--) - { - *pszDest++ = *pszTmp++; - } - - if( uiFlags & MINUS_FLAG) - { - // left justify - while( uiLength < uiWidth && uiMaxLen > 0) - { - *pszDest++ = ' '; - uiMaxLen--; - uiWidth--; - } - } - - *pszDest = 0; - pLogMessage->appendString( szOutputBuf); - - return( FERR_OK); -} - -/**************************************************************************** -Desc: Default error formatter. -****************************************************************************/ -FSTATIC RCODE flmLogErrorFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - F_LogMessage * pLogMessage, - f_va_list * args) -{ - RCODE rc = FERR_OK; - char szOutputBuf[ 128]; - FLMUINT uiErrorCode = (FLMUINT)f_va_arg( *args, unsigned); - - F_UNREFERENCED_PARM( ucFormatChar); - F_UNREFERENCED_PARM( uiWidth); - F_UNREFERENCED_PARM( uiPrecision); - F_UNREFERENCED_PARM( uiFlags); - - if( uiErrorCode < 0x0000FFFF) - { - f_sprintf( szOutputBuf, "%s (0x%4.4X, %u)", - FlmErrorString( (RCODE)uiErrorCode), - (unsigned)uiErrorCode, (unsigned)uiErrorCode); - } - else - { - f_sprintf( szOutputBuf, "0x%8.8X, %d", - (unsigned)uiErrorCode, (unsigned)uiErrorCode); - } - - pLogMessage->appendString( szOutputBuf); - - return( rc); -} - -/**************************************************************************** -Desc: Color formatter -****************************************************************************/ -FSTATIC RCODE flmLogColorFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - F_LogMessage * pLogMessage, - f_va_list * args) -{ - RCODE rc = FERR_OK; - - F_UNREFERENCED_PARM( ucFormatChar); - F_UNREFERENCED_PARM( args); - - if( uiFlags & PLUS_FLAG) - { - // Push a color onto the stack - - if( !uiWidth) - { - // Foreground - - pLogMessage->pushForegroundColor(); - } - else - { - // Background - - pLogMessage->pushBackgroundColor(); - } - } - else if( uiFlags & MINUS_FLAG) - { - // Pop a color from the color stack - - if( !uiWidth) - { - // Foreground - - pLogMessage->popForegroundColor(); - } - else - { - // Background - - pLogMessage->popBackgroundColor(); - } - } - else - { - eColorType foreground = (eColorType)(uiWidth + 1); - eColorType background = (eColorType)(uiPrecision + 1); - - // Set a new foreground and/or background color - - if( foreground >= FLM_NUM_COLORS || background >= FLM_NUM_COLORS) - { - goto Exit; - } - - pLogMessage->setColor( foreground, background); - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Default character formatter. - Prints the character specified by VALUE in 'c', or the '%' character. - Format: %[flags][width][.prec]'c' - flags = - width = - prec = -****************************************************************************/ -FSTATIC RCODE flmLogCharFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - F_LogMessage * pLogMessage, - f_va_list * args) -{ - char ucCharBuf[ 2]; - - F_UNREFERENCED_PARM( uiWidth); - F_UNREFERENCED_PARM( uiPrecision); - F_UNREFERENCED_PARM( uiFlags); - - ucCharBuf[ 0] = (FLMBYTE)((ucFormatChar == '%') - ? '%' - : f_va_arg( *args, int)); - ucCharBuf[ 1] = 0; - pLogMessage->appendString( ucCharBuf); - - return( FERR_OK); -} - -/**************************************************************************** -Desc: Unhandled format strings -****************************************************************************/ -FSTATIC RCODE flmLogNotHandledFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - F_LogMessage * pLogMessage, - f_va_list * args) -{ - F_UNREFERENCED_PARM( ucFormatChar); - F_UNREFERENCED_PARM( uiWidth); - F_UNREFERENCED_PARM( uiPrecision); - F_UNREFERENCED_PARM( uiFlags); - F_UNREFERENCED_PARM( args); - - pLogMessage->appendString( ""); - return( FERR_OK); -} - -/**************************************************************************** -Desc: Main entry point for printf functionality. -****************************************************************************/ -void flmLogPrintf( - F_LogMessage * pLogMessage, - const char * szFormatStr, ...) -{ - f_va_list args; - - f_va_start( args, szFormatStr); - (void)flmLogParsePrintfArgs( szFormatStr, (f_va_list *)&args, pLogMessage); - f_va_end( args); -} - -/**************************************************************************** -Desc: Printf routine that accepts a va_list argument -****************************************************************************/ -void flmLogVPrintf( - F_LogMessage * pLogMessage, - const char * szFormatStr, - f_va_list * args) -{ - (void)flmLogParsePrintfArgs( szFormatStr, args, pLogMessage); -} - -/**************************************************************************** -Desc: Returns an F_LogMessage object if logging is enabled for the - specified message type -****************************************************************************/ -F_LogMessage * flmBeginLogMessage( - FlmLogMessageType eMsgType, - FlmLogMessageSeverity eMsgSeverity) -{ - F_LogMessage * pNewMsg = NULL; - - if( gv_FlmSysData.pLogger) - { - pNewMsg = gv_FlmSysData.pLogger->beginMessage( eMsgType, eMsgSeverity); - } - - return( pNewMsg); -} - -/**************************************************************************** -Desc: F_Logger constructor -****************************************************************************/ -F_Logger::F_Logger() -{ - m_hMutex = F_MUTEX_NULL; - m_bSetupCalled = FALSE; - m_pbEnabledList = NULL; -} - -/**************************************************************************** -Desc: F_Logger destructor -****************************************************************************/ -F_Logger::~F_Logger() -{ - if (m_hMutex != F_MUTEX_NULL) - { - f_mutexUnlock( m_hMutex); - f_mutexDestroy( &m_hMutex); - } - - if( m_pbEnabledList) - { - f_free( &m_pbEnabledList); - } -} - -/**************************************************************************** -Desc: Set up the logger object -****************************************************************************/ -RCODE F_Logger::setupLogger( void) -{ - RCODE rc = FERR_OK; - - flmAssert( !m_bSetupCalled); - - if( RC_BAD( rc = f_mutexCreate( &m_hMutex))) - { - goto Exit; - } - - if (RC_BAD( rc = f_calloc( - ((FLMUINT)FLM_NUM_MESSAGE_TYPES) * sizeof( FLMBOOL), &m_pbEnabledList))) - { - goto Exit; - } - - m_bSetupCalled = TRUE; - -Exit: - - if( RC_BAD( rc)) - { - if( m_hMutex != F_MUTEX_NULL) - { - f_mutexDestroy( &m_hMutex); - } - - if( m_pbEnabledList) - { - f_free( &m_pbEnabledList); - } - } - - return( rc); -} - -/**************************************************************************** -Desc: Returns TRUE if the logger has been set up -****************************************************************************/ -FLMBOOL F_Logger::loggerIsSetup( void) -{ - return( m_bSetupCalled); -} - -/**************************************************************************** -Desc: Turns logging on for a specific message type -****************************************************************************/ -void F_Logger::enableMessageType( - FlmLogMessageType eMsgType) -{ - FLMUINT uiSlot = (FLMUINT)eMsgType; - - flmAssert( m_bSetupCalled); - - if( uiSlot < ((FLMUINT)FLM_NUM_MESSAGE_TYPES)) - { - m_pbEnabledList[ uiSlot] = TRUE; - } -} - -/**************************************************************************** -Desc: Turns logging on for all message types -****************************************************************************/ -void F_Logger::enableAllMessageTypes( void) -{ - FLMUINT uiLoop; - - flmAssert( m_bSetupCalled); - - for( uiLoop = 0; uiLoop < ((FLMUINT)FLM_NUM_MESSAGE_TYPES); uiLoop++) - { - m_pbEnabledList[ uiLoop] = TRUE; - } -} - -/**************************************************************************** -Desc: Turs logging off for a specific message type -****************************************************************************/ -void F_Logger::disableMessageType( - FlmLogMessageType eMsgType) -{ - FLMUINT uiSlot = (FLMUINT)eMsgType; - - flmAssert( m_bSetupCalled); - - if( uiSlot < ((FLMUINT)FLM_NUM_MESSAGE_TYPES)) - { - m_pbEnabledList[ uiSlot] = FALSE; - } -} - -/**************************************************************************** -Desc: Turns logging off for all message types -****************************************************************************/ -void F_Logger::disableAllMessageTypes( void) -{ - flmAssert( m_bSetupCalled); - f_memset( m_pbEnabledList, 0, - ((FLMUINT)FLM_NUM_MESSAGE_TYPES) * sizeof( FLMBOOL)); -} - -/**************************************************************************** -Desc: Returns TRUE if the specified message type is being logged -****************************************************************************/ -FLMBOOL F_Logger::messageTypeEnabled( - FlmLogMessageType eMsgType) -{ - FLMUINT uiSlot = (FLMUINT)eMsgType; - - flmAssert( m_bSetupCalled); - - if( uiSlot < ((FLMUINT)FLM_NUM_MESSAGE_TYPES)) - { - return( m_pbEnabledList[ uiSlot]); - } - - return( FALSE); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void F_Logger::lockLogger( void) -{ - flmAssert( m_bSetupCalled); - f_mutexLock( m_hMutex); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void F_Logger::unlockLogger( void) -{ - flmAssert( m_bSetupCalled); - f_mutexUnlock( m_hMutex); -} - -/**************************************************************************** -Desc: Pushes the current foreground color onto the color stack -****************************************************************************/ -void F_LogMessage::pushForegroundColor( void) -{ - if( m_uiForeColors < F_MAX_COLOR_STACK_SIZE) - { - m_foreColors[ F_MAX_COLOR_STACK_SIZE - - (++m_uiForeColors)] = m_currentForeColor; - } - else - { - m_uiForeColors++; - } -} - -/**************************************************************************** -Desc: Pushes the current background color onto the color stack -****************************************************************************/ -void F_LogMessage::pushBackgroundColor( void) -{ - if( m_uiBackColors < F_MAX_COLOR_STACK_SIZE) - { - m_backColors[ F_MAX_COLOR_STACK_SIZE - - (++m_uiBackColors)] = m_currentBackColor; - } - else - { - m_uiBackColors++; - } -} - -/**************************************************************************** -Desc: Pops the foreground color off of the top of the color stack -****************************************************************************/ -void F_LogMessage::popForegroundColor( void) -{ - eColorType foreColor = m_currentForeColor; - - // Pop a color from the color stack - - if( m_uiForeColors) - { - if( m_uiForeColors <= F_MAX_COLOR_STACK_SIZE) - { - foreColor = m_foreColors[ - F_MAX_COLOR_STACK_SIZE - m_uiForeColors]; - } - m_uiForeColors--; - } - - setColor( foreColor, m_currentBackColor); -} - -/**************************************************************************** -Desc: Pops the background color off of the top of the color stack -****************************************************************************/ -void F_LogMessage::popBackgroundColor( void) -{ - eColorType backColor = m_currentBackColor; - - // Pop a color from the color stack - - if( m_uiBackColors) - { - if( m_uiBackColors <= F_MAX_COLOR_STACK_SIZE) - { - backColor = m_backColors[ - F_MAX_COLOR_STACK_SIZE - m_uiBackColors]; - } - m_uiBackColors--; - } - - setColor( m_currentForeColor, backColor); -} - -/**************************************************************************** -Desc: Sets the foreground and background colors of a message -****************************************************************************/ -void F_LogMessage::setColor( - eColorType foreColor, - eColorType backColor) -{ - if( foreColor != m_currentForeColor || - backColor != m_currentBackColor) - { - m_currentForeColor = foreColor; - m_currentBackColor = backColor; - changeColor( m_currentForeColor, m_currentBackColor); - } -} - -/**************************************************************************** -Desc: Ends a logging message -****************************************************************************/ -void flmEndLogMessage( - F_LogMessage ** ppLogMessage) -{ - if( *ppLogMessage) - { - (*ppLogMessage)->endMessage(); - (*ppLogMessage)->Release(); - *ppLogMessage = NULL; - } -} diff --git a/flaim/src/flog.h b/flaim/src/flog.h deleted file mode 100644 index 26b9173..0000000 --- a/flaim/src/flog.h +++ /dev/null @@ -1,84 +0,0 @@ -//------------------------------------------------------------------------- -// Desc: Message logging - definitions. -// Tabs: 3 -// -// Copyright (c) 2001-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: flog.h 12329 2006-01-20 17:49:30 -0700 (Fri, 20 Jan 2006) ahodgkinson $ -//------------------------------------------------------------------------- - -#ifndef FLOG_H -#define FLOG_H - -#include "fpackon.h" -// IMPORTANT NOTE: No other include files should follow this one except -// for fpackoff.h - -// Special defines for use in the format string of flmLogPrintf - -#define F_BLACK "%0C" -#define F_BLUE "%1C" -#define F_GREEN "%2C" -#define F_CYAN "%3C" -#define F_RED "%4C" -#define F_PURPLE "%5C" -#define F_BROWN "%6C" -#define F_LIGHTGRAY "%7C" -#define F_DARKGRAY "%8C" -#define F_LIGHTBLUE "%9C" -#define F_LIGHTGREEN "%10C" -#define F_LIGHTCYAN "%11C" -#define F_LIGHTRED "%12C" -#define F_LIGHTPURPLE "%13C" -#define F_YELLOW "%14C" -#define F_WHITE "%15C" - -#define F_PUSHFORECOLOR "%+0C" -#define F_PUSHBACKCOLOR "%+1C" -#define F_POPFORECOLOR "%-0C" -#define F_POPBACKCOLOR "%-1C" - -#define F_PUSHCOLOR F_PUSHFORECOLOR F_PUSHBACKCOLOR -#define F_POPCOLOR F_POPFORECOLOR F_POPBACKCOLOR - -#define F_BLUE_ON_WHITE "%1.15C" - -// Logging functions for use within FLAIM - -F_LogMessage * flmBeginLogMessage( - FlmLogMessageType eMsgType, - FlmLogMessageSeverity eMsgSeverity); - -void flmLogPrintf( - F_LogMessage * pLogMessage, - const char * pszFormatStr, ...); - -void flmLogVPrintf( - F_LogMessage * pLogMessage, - const char * szFormatStr, - f_va_list * args); - -/**************************************************************************** -Desc: Ends a logging message -****************************************************************************/ -void flmEndLogMessage( - F_LogMessage ** ppLogMessage); - -#include "fpackoff.h" - -#endif diff --git a/flaim/src/flopen.cpp b/flaim/src/flopen.cpp index 22060e3..1c5a7c8 100644 --- a/flaim/src/flopen.cpp +++ b/flaim/src/flopen.cpp @@ -2238,7 +2238,7 @@ RCODE flmDbMonitor( { // Log a message - flmLogMessage( FLM_WARN_MESSAGE, FLM_YELLOW, FLM_BLACK, + flmLogMessage( F_WARN_MESSAGE, FLM_YELLOW, FLM_BLACK, "WARNING: The RFL has exceeded the specified size limit of %i64u", ui64RflDiskThreshold); diff --git a/flaim/src/fqcur.cpp b/flaim/src/fqcur.cpp index cae2d29..5a8cf7e 100644 --- a/flaim/src/fqcur.cpp +++ b/flaim/src/fqcur.cpp @@ -642,18 +642,21 @@ Desc: Frees memory allocated to an initialized cursor. The cursor handle FLMEXP RCODE FLMAPI FlmCursorFree( HFCURSOR * phCursor) { - CURSOR * pCursor = (CURSOR *)*phCursor; - F_LogMessage * pLogMsg = NULL; + CURSOR * pCursor = (CURSOR *)*phCursor; + IF_LogMessageClient * pLogMsg = NULL; flmAssert( pCursor != NULL); + + if( !gv_FlmSysData.pLogger) + { + return( FERR_OK); + } - // Log the query before getting rid of it - - if ((pLogMsg = flmBeginLogMessage( FLM_QUERY_MESSAGE, - FLM_DEBUG_MESSAGE)) != NULL) + if ((pLogMsg = gv_FlmSysData.pLogger->beginMessage( FLM_QUERY_MESSAGE, + F_DEBUG_MESSAGE)) != NULL) { flmLogQuery( pLogMsg, 0, pCursor); - flmEndLogMessage( &pLogMsg); + f_endLogMessage( &pLogMsg); } if (!pCursor->pCSContext && gv_FlmSysData.uiMaxQueries) @@ -668,7 +671,7 @@ FLMEXP RCODE FLMAPI FlmCursorFree( *phCursor = HFCURSOR_NULL; } - return FERR_OK; + return( FERR_OK); } /**************************************************************************** diff --git a/flaim/src/fqlog.cpp b/flaim/src/fqlog.cpp index cf8bc19..854b5d2 100644 --- a/flaim/src/fqlog.cpp +++ b/flaim/src/fqlog.cpp @@ -25,41 +25,41 @@ #include "flaimsys.h" FSTATIC void flmLogIndent( - F_LogMessage * pLogMsg, - FLMUINT uiIndent); + IF_LogMessageClient * pLogMsg, + FLMUINT uiIndent); FSTATIC void flmLogOperator( - F_LogMessage * pLogMsg, - QTYPES eOperator, - FLMBOOL bEndLine); + IF_LogMessageClient * pLogMsg, + QTYPES eOperator, + FLMBOOL bEndLine); FSTATIC void flmLogBinary( - F_LogMessage * pLogMsg, - FLMBYTE * pucBuf, - FLMUINT uiBufLen); + IF_LogMessageClient * pLogMsg, + FLMBYTE * pucBuf, + FLMUINT uiBufLen); FSTATIC void flmLogText( - F_LogMessage * pLogMsg, - const char * pucBuf, - FLMUINT uiBufLen); + IF_LogMessageClient * pLogMsg, + const char * pucBuf, + FLMUINT uiBufLen); FSTATIC void flmLogPredicate( - F_LogMessage * pLogMsg, - FLMUINT uiIndent, - FQNODE * pQNode); + IF_LogMessageClient * pLogMsg, + FLMUINT uiIndent, + FQNODE * pQNode); FSTATIC void flmLogSubQuery( - F_LogMessage * pLogMsg, - FLMUINT uiIndent, - QTYPES eParentOp, - SUBQUERY * pSubQuery); + IF_LogMessageClient * pLogMsg, + FLMUINT uiIndent, + QTYPES eParentOp, + SUBQUERY * pSubQuery); /**************************************************************************** Desc: This routine indents in the log. ****************************************************************************/ FSTATIC void flmLogIndent( - F_LogMessage * pLogMsg, - FLMUINT uiIndent) + IF_LogMessageClient * pLogMsg, + FLMUINT uiIndent) { char szIndent [100]; @@ -67,7 +67,7 @@ FSTATIC void flmLogIndent( { f_memset( szIndent, ' ', uiIndent); szIndent [uiIndent] = 0; - pLogMsg->setColor( FLM_LIGHTGRAY, FLM_BLACK); + pLogMsg->changeColor( FLM_LIGHTGRAY, FLM_BLACK); pLogMsg->appendString( szIndent); } } @@ -76,10 +76,9 @@ FSTATIC void flmLogIndent( Desc: This routine logs an operator ****************************************************************************/ FSTATIC void flmLogOperator( - F_LogMessage * pLogMsg, - QTYPES eOperator, - FLMBOOL bEndLine - ) + IF_LogMessageClient * pLogMsg, + QTYPES eOperator, + FLMBOOL bEndLine) { const char * pszOperator; @@ -163,11 +162,11 @@ FSTATIC void flmLogOperator( pLogMsg->pushBackgroundColor(); if (eOperator == FLM_LPAREN_OP || eOperator == FLM_RPAREN_OP) { - pLogMsg->setColor( FLM_CYAN, FLM_BLACK); + pLogMsg->changeColor( FLM_CYAN, FLM_BLACK); } else { - pLogMsg->setColor( FLM_BLUE, FLM_LIGHTGRAY); + pLogMsg->changeColor( FLM_BLUE, FLM_LIGHTGRAY); } pLogMsg->appendString( pszOperator); @@ -202,9 +201,9 @@ FINLINE void flmFormatByteToHex( Desc: This routine logs a buffer of binary bytes as ASCII hex. ****************************************************************************/ FSTATIC void flmLogBinary( - F_LogMessage * pLogMsg, - FLMBYTE * pucBuf, - FLMUINT uiBufLen) + IF_LogMessageClient * pLogMsg, + FLMBYTE * pucBuf, + FLMUINT uiBufLen) { FLMUINT uiLoop; FLMUINT uiOffset; @@ -303,9 +302,9 @@ FSTATIC void flmLogBinary( Desc: This routine logs text data. ****************************************************************************/ FSTATIC void flmLogText( - F_LogMessage * pLogMsg, - const char * pucBuf, - FLMUINT uiBufLen) + IF_LogMessageClient * pLogMsg, + const char * pucBuf, + FLMUINT uiBufLen) { FLMUINT uiLoop; FLMUINT uiOffset; @@ -412,10 +411,9 @@ FSTATIC void flmLogText( Desc: This routine logs the query criteria for a cursor. ****************************************************************************/ FSTATIC void flmLogPredicate( - F_LogMessage * pLogMsg, - FLMUINT uiIndent, - FQNODE * pQNode - ) + IF_LogMessageClient * pLogMsg, + FLMUINT uiIndent, + FQNODE * pQNode) { FLMUINT uiNestLevel = 0; QTYPES eCurrentOp; @@ -441,20 +439,20 @@ FSTATIC void flmLogPredicate( if (IS_VAL( eCurrentOp)) { - pLogMsg->setColor( FLM_WHITE, FLM_BLACK); + pLogMsg->changeColor( FLM_WHITE, FLM_BLACK); switch (eCurrentOp) { case FLM_BOOL_VAL: - flmLogPrintf( pLogMsg, "%u", + f_logPrintf( pLogMsg, "%u", (unsigned)pQNode->pQAtom->val.uiBool); break; case FLM_REC_PTR_VAL: case FLM_UINT32_VAL: - flmLogPrintf( pLogMsg, "%u", + f_logPrintf( pLogMsg, "%u", (unsigned)pQNode->pQAtom->val.uiVal); break; case FLM_INT32_VAL: - flmLogPrintf( pLogMsg, "%d", + f_logPrintf( pLogMsg, "%d", (int)pQNode->pQAtom->val.iVal); break; case FLM_BINARY_VAL: @@ -480,7 +478,7 @@ FSTATIC void flmLogPredicate( FLMUINT uiCnt; flmAssert( IS_FIELD( eCurrentOp)); - pLogMsg->setColor( FLM_YELLOW, FLM_BLACK); + pLogMsg->changeColor( FLM_YELLOW, FLM_BLACK); pLogMsg->appendString( "FLD:"); // Fields are from child to parent order - must count fields @@ -496,11 +494,11 @@ FSTATIC void flmLogPredicate( uiCnt--; if (uiCnt) { - flmLogPrintf( pLogMsg, "%u.", (unsigned)puiFldPath [uiCnt]); + f_logPrintf( pLogMsg, "%u.", (unsigned)puiFldPath [uiCnt]); } else { - flmLogPrintf( pLogMsg, "%u", (unsigned)puiFldPath [uiCnt]); + f_logPrintf( pLogMsg, "%u", (unsigned)puiFldPath [uiCnt]); } } } @@ -540,11 +538,10 @@ Exit: Desc: This routine logs the query criteria for a cursor. ****************************************************************************/ FSTATIC void flmLogSubQuery( - F_LogMessage * pLogMsg, - FLMUINT uiIndent, - QTYPES eParentOp, - SUBQUERY * pSubQuery - ) + IF_LogMessageClient * pLogMsg, + FLMUINT uiIndent, + QTYPES eParentOp, + SUBQUERY * pSubQuery) { FQNODE * pQNode; QTYPES eCurrentOp; @@ -560,7 +557,7 @@ FSTATIC void flmLogSubQuery( { flmLogIndent( pLogMsg, uiIndent); flmLogOperator( pLogMsg, FLM_LPAREN_OP, FALSE); - pLogMsg->setColor( FLM_WHITE, FLM_BLACK); + pLogMsg->changeColor( FLM_WHITE, FLM_BLACK); pLogMsg->appendString( ""); flmLogOperator( pLogMsg, FLM_RPAREN_OP, TRUE); goto Output_Opt_Info; @@ -603,13 +600,13 @@ FSTATIC void flmLogSubQuery( flmLogOperator( pLogMsg, FLM_LPAREN_OP, FALSE); if (hCursor == HFCURSOR_NULL) { - pLogMsg->setColor( FLM_WHITE, FLM_BLACK); + pLogMsg->changeColor( FLM_WHITE, FLM_BLACK); pLogMsg->appendString( " [EmbeddedPredicate] "); flmLogOperator( pLogMsg, FLM_RPAREN_OP, TRUE); } else { - pLogMsg->setColor( FLM_LIGHTGRAY, FLM_BLACK); + pLogMsg->changeColor( FLM_LIGHTGRAY, FLM_BLACK); pLogMsg->appendString( " [BeginEmbedded"); if (pSubQuery->OptInfo.eOptType == QOPT_USING_PREDICATE && pSubQuery->pPredicate == pQNode->pQAtom->val.pPredicate) @@ -627,7 +624,7 @@ FSTATIC void flmLogSubQuery( uiIndent -= 2; flmLogIndent( pLogMsg, uiIndent); flmLogOperator( pLogMsg, FLM_RPAREN_OP, FALSE); - pLogMsg->setColor( FLM_LIGHTGRAY, FLM_BLACK); + pLogMsg->changeColor( FLM_LIGHTGRAY, FLM_BLACK); pLogMsg->appendString( " [EndEmbedded]"); pLogMsg->newline(); } @@ -684,26 +681,26 @@ Output_Opt_Info: switch (pSubQuery->OptInfo.eOptType) { case QOPT_USING_INDEX: - flmLogPrintf( pLogMsg, F_WHITE "UsingIX=" F_YELLOW "%u", + f_logPrintf( pLogMsg, F_WHITE "UsingIX=" F_YELLOW "%u", pSubQuery->OptInfo.uiIxNum); - flmLogPrintf( pLogMsg, F_LIGHTGRAY ", KeyMatch="); + f_logPrintf( pLogMsg, F_LIGHTGRAY ", KeyMatch="); if (pSubQuery->OptInfo.bDoKeyMatch) { - flmLogPrintf( pLogMsg, F_GREEN "YES"); + f_logPrintf( pLogMsg, F_GREEN "YES"); } else { - flmLogPrintf( pLogMsg, F_RED "NO"); + f_logPrintf( pLogMsg, F_RED "NO"); } - flmLogPrintf( pLogMsg, F_LIGHTGRAY ", RecMatch="); + f_logPrintf( pLogMsg, F_LIGHTGRAY ", RecMatch="); if (pSubQuery->OptInfo.bDoRecMatch) { - flmLogPrintf( pLogMsg, F_GREEN "YES"); + f_logPrintf( pLogMsg, F_GREEN "YES"); } else { - flmLogPrintf( pLogMsg, F_RED "NO"); + f_logPrintf( pLogMsg, F_RED "NO"); } pucFromKey = NULL; @@ -716,24 +713,24 @@ Output_Opt_Info: // Show the from key - flmLogPrintf( pLogMsg, + f_logPrintf( pLogMsg, F_LIGHTGRAY ", FromKeyLen=" F_YELLOW "%u" F_LIGHTGRAY ", FromKey=(", uiFromKeyLen); if (uiFromKeyLen) { - pLogMsg->setColor( FLM_YELLOW, FLM_BLACK); + pLogMsg->changeColor( FLM_YELLOW, FLM_BLACK); flmLogBinary( pLogMsg, pucFromKey, uiFromKeyLen); } else { - flmLogPrintf( pLogMsg, F_YELLOW ""); + f_logPrintf( pLogMsg, F_YELLOW ""); } - flmLogPrintf( pLogMsg, F_LIGHTGRAY ")"); + f_logPrintf( pLogMsg, F_LIGHTGRAY ")"); // Show the until key. - flmLogPrintf( pLogMsg, + f_logPrintf( pLogMsg, F_LIGHTGRAY ", UntilKeyLen=" F_YELLOW "%u" F_LIGHTGRAY ", UntilExcl=" F_YELLOW "%s" F_LIGHTGRAY ", UntilKey=(", @@ -743,68 +740,68 @@ Output_Opt_Info: : "No")); if (uiUntilKeyLen) { - pLogMsg->setColor( FLM_YELLOW, FLM_BLACK); + pLogMsg->changeColor( FLM_YELLOW, FLM_BLACK); flmLogBinary( pLogMsg, pucUntilKey, uiUntilKeyLen); } else { - flmLogPrintf( pLogMsg, F_YELLOW ""); + f_logPrintf( pLogMsg, F_YELLOW ""); } - flmLogPrintf( pLogMsg, F_LIGHTGRAY ")"); + f_logPrintf( pLogMsg, F_LIGHTGRAY ")"); f_free( &pucFromKey); f_free( &pucUntilKey); } break; case QOPT_USING_PREDICATE: - flmLogPrintf( pLogMsg, F_WHITE "Using Embedded Predicate"); + f_logPrintf( pLogMsg, F_WHITE "Using Embedded Predicate"); break; case QOPT_SINGLE_RECORD_READ: - flmLogPrintf( pLogMsg, F_WHITE "Single Record Read, DRN: " + f_logPrintf( pLogMsg, F_WHITE "Single Record Read, DRN: " F_YELLOW "%u", pSubQuery->OptInfo.uiDrn); break; case QOPT_PARTIAL_CONTAINER_SCAN: - flmLogPrintf( pLogMsg, F_WHITE "Partial Container Scan"); + f_logPrintf( pLogMsg, F_WHITE "Partial Container Scan"); //VISIT: Output from and until DRNs - need a method from //pSubQuery->pFSDataCursor to return them. break; case QOPT_FULL_CONTAINER_SCAN: - flmLogPrintf( pLogMsg, F_WHITE "Full Container Scan"); + f_logPrintf( pLogMsg, F_WHITE "Full Container Scan"); break; default: - flmLogPrintf( pLogMsg, F_WHITE "Unknown optimization"); + f_logPrintf( pLogMsg, F_WHITE "Unknown optimization"); break; } - flmLogPrintf( pLogMsg, F_LIGHTGRAY "}\n"); + f_logPrintf( pLogMsg, F_LIGHTGRAY "}\n"); flmLogIndent( pLogMsg, uiIndent); pLogMsg->appendString( "{Stats: "); - flmLogPrintf( pLogMsg, F_LIGHTGRAY "Container=" F_WHITE "%u", + f_logPrintf( pLogMsg, F_LIGHTGRAY "Container=" F_WHITE "%u", (unsigned)pSubQuery->SQStatus.uiContainerNum); - flmLogPrintf( pLogMsg, F_LIGHTGRAY ", Matched=" F_WHITE "%u", + f_logPrintf( pLogMsg, F_LIGHTGRAY ", Matched=" F_WHITE "%u", (unsigned)pSubQuery->SQStatus.uiMatchedCnt); if (pSubQuery->SQStatus.uiNumRejectedByCallback) { - flmLogPrintf( pLogMsg, F_LIGHTGRAY ", CallbackRejected=" F_WHITE "%u", + f_logPrintf( pLogMsg, F_LIGHTGRAY ", CallbackRejected=" F_WHITE "%u", (unsigned)pSubQuery->SQStatus.uiNumRejectedByCallback); } if (pSubQuery->SQStatus.uiDupsEliminated) { - flmLogPrintf( pLogMsg, F_LIGHTGRAY ", DupsElim=" F_WHITE "%u", + f_logPrintf( pLogMsg, F_LIGHTGRAY ", DupsElim=" F_WHITE "%u", (unsigned)pSubQuery->SQStatus.uiDupsEliminated); } if (pSubQuery->SQStatus.uiKeysTraversed || pSubQuery->SQStatus.uiKeysRejected) { - flmLogPrintf( pLogMsg, F_LIGHTGRAY ", KeysFailed=" F_WHITE "%u of %u", + f_logPrintf( pLogMsg, F_LIGHTGRAY ", KeysFailed=" F_WHITE "%u of %u", (unsigned)pSubQuery->SQStatus.uiKeysRejected, (unsigned)pSubQuery->SQStatus.uiKeysTraversed); } @@ -812,7 +809,7 @@ Output_Opt_Info: if (pSubQuery->SQStatus.uiRefsTraversed || pSubQuery->SQStatus.uiRefsRejected) { - flmLogPrintf( pLogMsg, F_LIGHTGRAY ", RefsFailed=" F_WHITE "%u of %u", + f_logPrintf( pLogMsg, F_LIGHTGRAY ", RefsFailed=" F_WHITE "%u of %u", (unsigned)pSubQuery->SQStatus.uiRefsRejected, (unsigned)pSubQuery->SQStatus.uiRefsTraversed); } @@ -821,7 +818,7 @@ Output_Opt_Info: pSubQuery->SQStatus.uiRecsRejected || pSubQuery->SQStatus.uiRecsNotFound) { - flmLogPrintf( pLogMsg, F_LIGHTGRAY ", RecsFetched=" F_WHITE "%u" + f_logPrintf( pLogMsg, F_LIGHTGRAY ", RecsFetched=" F_WHITE "%u" F_LIGHTGRAY ", RecsRejected=" F_WHITE "%u" F_LIGHTGRAY ", RecsNotFound=" F_WHITE "%u", (unsigned)pSubQuery->SQStatus.uiRecsFetchedForEval, @@ -829,7 +826,7 @@ Output_Opt_Info: (unsigned)pSubQuery->SQStatus.uiRecsNotFound); } - flmLogPrintf( pLogMsg, F_LIGHTGRAY "}\n"); + f_logPrintf( pLogMsg, F_LIGHTGRAY "}\n"); if (bIndentOptInfo) { @@ -842,9 +839,9 @@ Output_Opt_Info: Desc: This routine logs the query criteria for a cursor. ****************************************************************************/ void flmLogQuery( - F_LogMessage * pLogMsg, - FLMUINT uiIndent, - CURSOR * pCursor) + IF_LogMessageClient * pLogMsg, + FLMUINT uiIndent, + CURSOR * pCursor) { SUBQUERY * pSubQuery; QTYPES eParentOp = (pCursor->pSubQueryList && @@ -854,7 +851,7 @@ void flmLogQuery( if (!uiIndent) { - pLogMsg->setColor( FLM_LIGHTGRAY, FLM_BLACK); + pLogMsg->changeColor( FLM_LIGHTGRAY, FLM_BLACK); pLogMsg->appendString( "QUERY CRITERIA:"); if (!pCursor->pSubQueryList) { diff --git a/flaim/src/fquery.h b/flaim/src/fquery.h index 9934927..7b9ed24 100644 --- a/flaim/src/fquery.h +++ b/flaim/src/fquery.h @@ -577,9 +577,9 @@ RCODE flmCurGraftNode( FQNODE * * ppQTree); void flmLogQuery( - F_LogMessage * pLogMsg, - FLMUINT uiIndent, - CURSOR * pCursor); + IF_LogMessageClient * pLogMsg, + FLMUINT uiIndent, + CURSOR * pCursor); FINLINE void flmCurFinishTransactions( CURSOR * pCursor, diff --git a/flaim/src/fslfileu.cpp b/flaim/src/fslfileu.cpp index 4803b3e..2dc4ba7 100644 --- a/flaim/src/fslfileu.cpp +++ b/flaim/src/fslfileu.cpp @@ -738,7 +738,7 @@ void flmLogIndexingProgress( FLMUINT uiLastDrn) { flmLogMessage( - FLM_DEBUG_MESSAGE, + F_DEBUG_MESSAGE, FLM_YELLOW, FLM_BLACK, uiLastDrn diff --git a/flaim/src/fstructs.h b/flaim/src/fstructs.h index d6355ed..a2ddccd 100644 --- a/flaim/src/fstructs.h +++ b/flaim/src/fstructs.h @@ -886,7 +886,7 @@ typedef struct FLMSYSDATA HTTPCONFIGPARAMS HttpConfigParms; FLMUINT uiMaxFileSize; - F_Logger * pLogger; + IF_LoggerClient * pLogger; IF_SlabManager * pSlabManager; IF_ThreadMgr * pThreadMgr; diff --git a/flaim/src/fsysdata.cpp b/flaim/src/fsysdata.cpp index 048e2fe..993c757 100644 --- a/flaim/src/fsysdata.cpp +++ b/flaim/src/fsysdata.cpp @@ -666,7 +666,7 @@ DONT_PREALLOCATE: // Log a message indicating that we couldn't pre-allocate // the cache - flmLogMessage( FLM_DEBUG_MESSAGE, FLM_YELLOW, FLM_BLACK, + flmLogMessage( F_DEBUG_MESSAGE, FLM_YELLOW, FLM_BLACK, "WARNING: Couldn't pre-allocate cache."); goto DONT_PREALLOCATE; @@ -1418,10 +1418,8 @@ FLMEXP RCODE FLMAPI FlmConfig( f_mutexLock( gv_FlmSysData.hShareMutex); if( !gv_FlmSysData.pLogger && Value1) { - gv_FlmSysData.pLogger = (F_Logger *)Value1; - gv_FlmSysData.pLogger->lockLogger(); + gv_FlmSysData.pLogger = (IF_LoggerClient *)Value1; gv_FlmSysData.pLogger->AddRef(); - gv_FlmSysData.pLogger->unlockLogger(); } f_mutexUnlock( gv_FlmSysData.hShareMutex); break; @@ -2461,11 +2459,7 @@ FSTATIC void flmCleanup( void) if( gv_FlmSysData.pLogger) { - gv_FlmSysData.pLogger->lockLogger(); - if( gv_FlmSysData.pLogger->Release() >= 1) - { - gv_FlmSysData.pLogger->unlockLogger(); - } + gv_FlmSysData.pLogger->Release(); gv_FlmSysData.pLogger = NULL; } diff --git a/flaim/src/imonfsys.cpp b/flaim/src/imonfsys.cpp index 997d931..5b4fd51 100644 --- a/flaim/src/imonfsys.cpp +++ b/flaim/src/imonfsys.cpp @@ -608,19 +608,6 @@ void F_FlmSysDataPage::write_data( gv_FlmSysData.uiMaxFileSize, (bHighlight = !bHighlight)); - // pLogger - Logger - f_sprintf( (char *)pszTemp, "%s/Logger", - m_pszURLString); - - printHTMLLink( - "pLogger", - "F_Logger *", - (void *)&gv_FlmSysData, - (void *)&gv_FlmSysData.pLogger, - (void *)gv_FlmSysData.pLogger, - (char *)pszTemp, - (bHighlight = !bHighlight)); - printTableEnd(); Exit: diff --git a/flaim/src/scache.cpp b/flaim/src/scache.cpp index d0a934e..611d95b 100644 --- a/flaim/src/scache.cpp +++ b/flaim/src/scache.cpp @@ -7822,7 +7822,7 @@ FSTATIC RCODE scaFinishCheckpoint( uiFirstDbInactiveSecs = FLM_TIMER_UNITS_TO_SECS( uiElapTime); flmLogMessage( - FLM_DEBUG_MESSAGE, + F_DEBUG_MESSAGE, FLM_YELLOW, FLM_BLACK, "Killed transaction 0x%08X." @@ -7862,7 +7862,7 @@ FSTATIC RCODE scaFinishCheckpoint( uiFirstDbInactiveSecs = FLM_TIMER_UNITS_TO_SECS( uiElapTime); flmLogMessage( - FLM_DEBUG_MESSAGE, + F_DEBUG_MESSAGE, FLM_YELLOW, FLM_BLACK, "Waiting for transaction 0x%08X to complete."