PDA

View Full Version : Log record save and delete



Curtis Krauskopf
30-Jan-2005, 06:18 AM
The purpose of this module is to help a developer discover why records are
being mysteriously deleted or overwritten. It does this by logging the key
fields and other important information when a specific datafile is saved or
deleted. This solution is only suitable for character-mode DataFlex.

This solution falls under the category of "desperate times call for
desperate measures". You really should only do this if you have exhausted
every other avenue available to solve the problem. The good news is that
every time I've used this technique, I've been able to find the problem as
soon as a user caused the problem to occur.

The overall scheme of this technique is to insert some code into an FMAC
macro that saves and deletes records. The code will log each time a record
is created or updated for a specific file. Because the code is inserted at
the macro level, every source file, module, package, and include file
anywhere in the application that uses SAVE, SAVERECORD and DELETE on the
monitored file will have the transaction logged.

This solution is compatible with every known technique for saving and
deleting records:

Save filename
Save (integer)
Save indirect_file.recnum
SaveRecord filename
SaveRecord (integer)
SaveRecord indirect_file.recnum
Delete filename
Delete (integer)
Delete indirect_file.recnum

Other macros, such as the ENTER macro, will need to be slightly modified to
log saves in those macros too. If none of your programs use an ENTER macro,
then you can skip that part.

This solution is designed to require a minimum number of changes to the
source code. Three lines are required to be inserted at the top of each
file. The lines are simple enough that a DataFlex program could be written
to do this insertion, or if you're handy with PERL, AWK or your editor's
macro language, you could use any of those techniques to insert those lines
too.

TDM_LOG.ZIP manifest:
README.TXT
TDM_LOG.DAT
TDM_LOG.DEF
TDM_LOG.FD
TDM_LOG.HDR
TDM_LOG.PKG
TDM_LOG.TAG
TESTING/T1.SRC
TESTING/TEST1.DAT
TESTING/TEST1.DEF
TESTING/TEST1.FD
TESTING/TEST1.HDR
TESTING/TEST1.TAG

Curtis Krauskopf
The Database Managers, Inc.
http://www.decompile.com

Eric Vaughen
31-Jan-2005, 09:12 AM
Thanks... I will check it out...

Curtis Krauskopf wrote:
> The purpose of this module is to help a developer discover why records are
> being mysteriously deleted or overwritten. It does this by logging the key
> fields and other important information when a specific datafile is saved or
> deleted. This solution is only suitable for character-mode DataFlex.
>
> This solution falls under the category of "desperate times call for
> desperate measures". You really should only do this if you have exhausted
> every other avenue available to solve the problem. The good news is that
> every time I've used this technique, I've been able to find the problem as
> soon as a user caused the problem to occur.
>
> The overall scheme of this technique is to insert some code into an FMAC
> macro that saves and deletes records. The code will log each time a record
> is created or updated for a specific file. Because the code is inserted at
> the macro level, every source file, module, package, and include file
> anywhere in the application that uses SAVE, SAVERECORD and DELETE on the
> monitored file will have the transaction logged.
>
> This solution is compatible with every known technique for saving and
> deleting records:
>
> Save filename
> Save (integer)
> Save indirect_file.recnum
> SaveRecord filename
> SaveRecord (integer)
> SaveRecord indirect_file.recnum
> Delete filename
> Delete (integer)
> Delete indirect_file.recnum
>
> Other macros, such as the ENTER macro, will need to be slightly modified to
> log saves in those macros too. If none of your programs use an ENTER macro,
> then you can skip that part.
>
> This solution is designed to require a minimum number of changes to the
> source code. Three lines are required to be inserted at the top of each
> file. The lines are simple enough that a DataFlex program could be written
> to do this insertion, or if you're handy with PERL, AWK or your editor's
> macro language, you could use any of those techniques to insert those lines
> too.
>
> TDM_LOG.ZIP manifest:
> README.TXT
> TDM_LOG.DAT
> TDM_LOG.DEF
> TDM_LOG.FD
> TDM_LOG.HDR
> TDM_LOG.PKG
> TDM_LOG.TAG
> TESTING/T1.SRC
> TESTING/TEST1.DAT
> TESTING/TEST1.DEF
> TESTING/TEST1.FD
> TESTING/TEST1.HDR
> TESTING/TEST1.TAG
>
> Curtis Krauskopf
> The Database Managers, Inc.
> http://www.decompile.com
>
>