palmtree with sun behind it CONTACT US
Phone: (412) 835-9417
Email: sales@vss3.com

Tip #26 - LOGTEXT - Logging Information

It is helpful to make a timestamp entry to track a function or event in your system.  These logs can help verify that a function was completed on schedule, who is doing what, what selection was given, errors encountered.  It can be helpful to track items that are required.

I am sure once you try this you can think of many reasons to make use of this simple logging technique.

A few environment variables need to be defined first to set up the name of the log file and if the data will be appended or overwrite the file each time an entry is made.  These variables can be added to the configuration file or to the processing as I have shown here.

1 ------- - - - - - - - - - - - - - - - -
If:         'set these variables at the  beginning of the processing or in config file
Then: putenv "PFLOGAPPEND","ON"
2 ------- - - - - - - - - - - - - - - - -
If: @OS ne "DOS"
Then: putenv "LOGFILE",getenv("PFPROG"){"/fpmerge/logfile.txt"
3 ------- - - - - - - - - - - - - - - - -
If: @OS eq "DOS"
Then: putenv "LOGFILE",getenv("PFPROG"){"\ "{"logfile.txt"

PUTENV - is used to assign a value to the variable indicated.

PUTENV "PFLOGAPPEND","ON"  will "set PFLOGAPPEND=ON" for the rest of the processing.

Then call the following routine whenever you have the need to log something

declare local count(3,.0,g)    ' this requires 4.8 but could be done with a simple dummy variable.

count = count+"1"    'somewhere in table count the invoices with this line.

15 ------- - - - - - - - - - - - - - - - -
     If:  @rs eq "1"        ' done on first pass through 
Then: a="Printed Invoice Starting with number:"<iv; gosub logit
16 ------- - - - - - - - - - - - - - - - -
     If:  count eq @ts       
Then: a="Invoices Printed:"<@ts;gosub logit
17 ------- - - - - - - - - - - - - - - - -
    If: 
Then: end

The actual logic that actually makes the entry in the log file is with the command LOGTEXT "   text to write to the file  "

It is as easy as that.  Just put the information that you wish in a dummy variable and issue the LOGTEXT command.  If you have the PFLOGAPPEND=ON it will add to the end of the file.  If you have PFLOGAPPEND=OFF then the information is added to the end of the file.  I find this the most helpful type of log file. How much easier can it be.

23 ------- - - - - - - - - - - - - - - - -
logit   If: @id ne ""        ' subroutine to make log entries
     Then: y=y<"by"<@id
24 ------- - - - - - - - - - - - - - - - -
If:     'set LOGAPPEND and PFLOGFILE in config table to properly collect
Then: logtext @td<@tm<y
25 ------- - - - - - - - - - - - - - - - -
If: 
Then: logtext "----------------"
26 ------- - - - - - - - - - - - - - - - -
If: 
Then: return

I hope you will find this as useful as I have.


Cut from next line down.

::putenv "PFLOGAPPEND","ON":

:@OS ne "DOS":putenv "LOGFILE",getenv("PFPROG"){"/fpmerge/logfile.txt":

:@OS eq "DOS":putenv "LOGFILE",getenv("PFPROG"){"\ "{"logfile.txt":

 

logit: 'subroutine to write information::

::y="Invoices printed":

:@id ne "":y=y<"by"<@id:

:'set LOGAPPEND and PFLOGFILE in config table to properly collect:logtext @td<@tm<y:

::logtext " INVOICES PROCESSED-"<@ts:

::logtext "----------------":

::return:

Cut to HERE


If you highlight the code, right click and select copy.  Then go to a DOS editor, and open a file, right click and Paste.  That will put the file down, then save it as a text file.  Copy it to the file you created and call it datev.prc.  It should then load into Define Processing and you can verify that it passes the syntax test.

Written by Nancy Palmquist

Copyright, 1997 by Virtual Software Systems.  All rights reserved.

Contact Us by: Email to Virtual Software Systems or Phone: (412) 835-9417