2009-01-16 22:05 UTC+0100 Francesco Saverio Giudice (info/at/fsgiudice.com)

* harbour/source/rdd/usrrdd/rdds/logrdd.prg
    - removed sample at end of file
    * typos
  * harbour/source/rdd/usrrdd/example/exlog.prg
    * Altered to reflect new codeblock parameters and added
      local MyToString() function to see how handle commands.
This commit is contained in:
Francesco Saverio Giudice
2009-01-16 21:07:11 +00:00
parent 5b25596549
commit bd83bd4675
3 changed files with 57 additions and 57 deletions

View File

@@ -8,6 +8,14 @@
2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
*/
2009-01-16 22:05 UTC+0100 Francesco Saverio Giudice (info/at/fsgiudice.com)
* harbour/source/rdd/usrrdd/rdds/logrdd.prg
- removed sample at end of file
* typos
* harbour/source/rdd/usrrdd/example/exlog.prg
* Altered to reflect new codeblock parameters and added
local MyToString() function to see how handle commands.
2009-01-16 21:48 UTC+0100 Francesco Saverio Giudice (info/at/fsgiudice.com)
* harbour/source/rdd/usrrdd/rdds/logrdd.prg
+ Added new function hb_LogRddValueToText()

View File

@@ -26,10 +26,11 @@ PROCEDURE Main()
// Activate Logging, it can be stopped/started at any moment
hb_LogRddActive( .T. )
// Uncomment next command to change logged string to standard LOGRDD file
// hb_LogRddMsgLogBlock( {|cTag, cRDDName, cCmd, nWA, cMsg| DToS( Date() ) + " / " + Time() + " " + cTag + ": " + PadR( cRDDName + "_" + cCmd, 20 ) + " - " + cMsg } )
// Uncomment next command to change standard destination logged string
// hb_LogRddUserLogBlock( {|cTag, cRDDName, cCmd, nWA, cMsg| hb_toOutDebug( DToS( Date() ) + " : " + Time() + " " + cTag + ": " + PadR( cRDDName + "_" + cCmd, 20 ) + " - " + cMsg + "\n\r" ) } )
// Uncomment next command to change logged string that I have to return to standard LOGRDD file
// hb_LogRddMsgLogBlock( {|cTag, cRDDName, cCmd, nWA, xPar1, xPar2, xPar3| MyToString( cTag, cRDDName, cCmd, nWA, xPar1, xPar2, xPar3 ) } )
// Uncomment next command to change standard destination of my logged string
// hb_LogRddUserLogBlock( {|cTag, cRDDName, cCmd, nWA, xPar1, xPar2, xPar3| hb_toOutDebug( MyToString( cTag, cRDDName, cCmd, nWA, xPar1, xPar2, xPar3 ) + "\n\r" ) } )
// Start program logic
@@ -43,7 +44,46 @@ PROCEDURE Main()
APPEND BLANK
field->name := "Francesco"
RETURN
RETURN
STATIC FUNCTION MyToString( cCmd, nWA, xPar1, xPar2, xPar3 )
LOCAL cString
DO CASE
CASE cCmd == "CREATE"
// Parameters received: xPar1 = aOpenInfo
cString := xPar1[ UR_OI_NAME ]
CASE cCmd == "CREATEFIELDS"
// Parameters received: xPar1 = aStruct
cString := hb_ValToExp( xPar1 )
CASE cCmd == "OPEN"
// Parameters received: xPar1 = aOpenInfo
// cString := 'Table : "' + xPar1[ UR_OI_NAME ] + '", Alias : "' + Alias() + '", WorkArea : ' + LTrim( Str( nWA ) )
// In this example I don't want to log Open Command
CASE cCmd == "CLOSE"
// Parameters received: xPar1 = cTableName, xPar2 = cAlias
//cString := 'Table : "' + xPar1 + '", Alias : "' + xPar2 + '", WorkArea : ' + LTrim( Str( nWA ) )
// In this example I don't want to log Close Command
CASE cCmd == "APPEND"
// Parameters received: xPar1 = lUnlockAll
cString := Alias() + "->RecNo() = " + LTrim( Str( RecNo() ) )
CASE cCmd == "DELETE"
// Parameters received: none
cString := Alias() + "->RecNo() = " + LTrim( Str( RecNo() ) )
CASE cCmd == "RECALL"
// Parameters received: none
cString := Alias() + "->RecNo() = " + LTrim( Str( RecNo() ) )
CASE cCmd == "PUTVALUE"
// Parameters received: xPar1 = nField, xPar2 = xValue, xPar3 = xOldValue
#ifndef __XHARBOUR__
HB_UNUSED_VAR( xPar3 ) // Here don't log previous value
#endif
cString := Alias() + "(" + LTrim( Str( RecNo() ) ) + ")->" + PadR( FieldName( xPar1 ), 10 ) + " := " + hb_LogRddValueToText( xPar2 )
CASE cCmd == "ZAP"
// Parameters received: none
cString := 'Alias : "' + Alias() + ' Table : "' + dbInfo( DBI_FULLPATH ) + '"'
ENDCASE
RETURN cString
FUNCTION hb_LogRddInherit()
RETURN "DBFCDX"
RETURN "DBFCDX"

View File

@@ -54,7 +54,8 @@
* A simple RDD which introduce logging to file. It inheriths from
* any existent RDD but if you write / replace / delete something
* on tables it writes changes in a log file.
* An example is avalaible at bottom of this file.
* An example is avalaible at
* harbour/source/rdd/usrrdd/example/exlog.prg
*/
#include "rddsys.ch"
@@ -463,7 +464,7 @@ STATIC PROCEDURE ToLog( cCmd, nWA, xPar1, xPar2, xPar3 )
bMsgLogBlock := aRDDData[ ARRAY_MSGLOGBLOCK ]
// If defined a codeblock I send to user infos and he have to return a formatted string
// If defined a codeblock I send to user infos and he has to return a formatted string
// Look at local ToString() function for details
IF HB_ISBLOCK( bMsgLogBlock )
cLog := Eval( bMsgLogBlock, cTag, cRDDName, cCmd, nWA, xPar1, xPar2, xPar3 )
@@ -486,52 +487,3 @@ STATIC PROCEDURE ToLog( cCmd, nWA, xPar1, xPar2, xPar3 )
ENDIF
RETURN
/*****************************************************************
EXAMPLE:
#include "dbinfo.ch"
// Request for LOGRDD rdd driver
REQUEST LOGRDD
// Here put Request for RDD you want to inherit then add
// function hb_LogRddInherit() (see at bottom)
REQUEST DBFCDX
PROCEDURE Main()
// Set LOGRDD as default RDD otherwise I have to set explicitly use
// with DRIVER option
RDDSetDefault( "LOGRDD" )
// Adding Memofile Info
rddInfo( RDDI_MEMOVERSION, DB_MEMOVER_CLIP, "LOGRDD" )
// Define Log File Name and position
hb_LogRddLogFileName( "logs\changes.log" )
// Define Tag to add for each line logged
hb_LogRddTag( NETNAME() + "\" + hb_USERNAME() )
// Activate Logging, it can be stopped/started at any moment
hb_LogRddActive( .T. )
// Uncomment next command to change logged string to standard LOGRDD file
// hb_LogRddMsgLogBlock( {|cTag, cRDDName, cCmd, nWA, cMsg| DToS( Date() ) + " / " + Time() + " " + cTag + ": " + PadR( cRDDName + "_" + cCmd, 20 ) + " - " + cMsg } )
// Uncomment next command to change standard destination logged string
// hb_LogRddUserLogBlock( {|cTag, cRDDName, cCmd, nWA, cMsg| hb_toOutDebug( DToS( Date() ) + " : " + Time() + " " + cTag + ": " + PadR( cRDDName + "_" + cCmd, 20 ) + " - " + cMsg + "\n\r" ) } )
// Start program logic
// Open a table with logging (default RDD is LOGRDD)
USE test
field->name := "Francesco"
CLOSE
// Open a table without logging
USE test DRIVER "DBFCDX"
....
RETURN
FUNCTION hb_LogRddInherit()
RETURN "DBFCDX"
*******************************************************************/