Table of Contents

Module to handle processing logs

Module LOGMOD Module to handle processing logs

Description

Module to supply the functions necessary to create a logfile and an
associated event describing the action which took place.
The Module has to stay independent. Thus no reference to
SYSMOD routines or fields might be taken.


LOGMOD - Creating Process Logs

The purpose of this module is to enable the easy and error-free creation of process logs in transactions which are used in technical areas like reorganizations, cleanup processes or manager running in background.

The module provides the following functionality:

To display a log within other transactions, the following steps need to be taken:

Available Routines

StartDefLog

Should be called in the Init to generate the default header with

Processing Log Requirements

The following has to be considered when implementing a processing log:

  1. The processing context must be identifiable in the log, i.e. which settings have been used in which environment for the processing. These data (as far as they are not modifiable) can be displayed at the beginning of the log once.
  2. If there exist multiple processing steps, the intermediate results should be displayed in order to show the progress of the procedure.
  3. A processing cycle or a longer-term closed action should be stated should be specified at the end and at the beginning of each log.
  4. In case large numbers of elements are processed, the numbers of the processed elements should be displayed.
  5. All error or warning messages have to be displayed.
  6. The log entries have to be that clear, that they could be understood by people, who do not know the implemented logic.
    Specifying an INR, for example, is technically unambiguous, but has absolutely no meaning for a 'common' user. If  the EXTKEY or the  OWNREF or the like are specified besides the INR provides much more understandable information in order to identify the object that causes an error.
  7. A log may not be too text-laden.
    The important information may not be hidden by a host of unimportant details or texts. In particular, recurring data/texts should not be displayed.
    A switch that is used to set the level of detail of a log can be helpful. For example, if always the same path has to be displayed with varying file names , this path should be displayed once, followed by the file names.
  8. A log must have a begin and end message.
    Thereby canceled logs can be identified and the total running time can be determined easily.

Type Marking

An additional type can be passed when calling. This type describes the meaning of the line or it marks the log line with a flag.

Type at WriteLine Description
Empty Normal process, pre- or post-processing line.
LogmodInfo Special state that is remarkable, but is not really an error.
LogmodWarning Error state, that can be revoked, for example, by repeating (e.g. a record is locked and the current processing can unproblematically be started again a second time)
LogmodError Serious error state, that needs to be handled by a system administrator.

Properties

Property YES/NO
Single page frame Yes
Show toolbar Yes
Show menu Yes
Show statusbar Yes
Show hint Yes
Fit panel size Yes



Datafields

Name Description Data Type Len Dec. View lines View type Inst. Visible Codetable
EVTTXT Passed Event description Block 80 4 4 Block Yes Private
MAXSIZ Maximum size of the logfile Numeric 10 0 Edit Yes Public
PENLINCNT Count of written lines after last LogCommit Numeric 8 0 Edit Yes Read only
LOGFIL Filename of logfile Text 80 1 Edit Yes Read only
SHRLOG Name of the shared log Text 20 1 Edit Yes Read only
FLGCNTI Count of Flag Info Numeric 8 0 Edit Yes Read only
FLGCNTW Count of Flag Warning Numeric 8 0 Edit Yes Read only
FLGCNTE Count of Flag Error Numeric 8 0 Edit Yes Read only
FLGCNTO Count of other Flags Numeric 8 0 Edit Yes Read only
NXTDAT Date of next check of size Date 12 0 Date Yes Private
NXTTIM Time of next check of size Numeric 6 4 Edit Yes Private
NXTADD Timegap between checks Numeric 6 4 Edit Yes Public
SWTLST List of all hours where a switch should occur Text 25 1 Edit Yes Public
LOGSUBDIR Subdir under Partition LOG ( YYYYMM ) Text 6 1 Edit Yes Public
MOVERRFLG Logfile move error Text 40 1 Edit Yes Public Embedded



Datafield Description and Properties

Datafield EVTTXT Passed Event description

Description

The originally passed textual description of the event. This Text concatenated with the filename of the Logfile will be stored in the Event.


Datafield MAXSIZ Maximum size of the logfile

Description

This field holds the maximum size of a logfile in bytes. If a log grows beyond this size an automatic switch to a new log will take place. The default value preset in init of LOGMOD is 3096000 which stands for a size of 3 MB.


Datafield LOGFIL Filename of logfile

Description

Name of the logfile where the logentries are written to. The field holds the complete filepath. The filename is generated by LOGMOD. If the file could not be created or opened two blanks are stored in the field.


Datafield SHRLOG Name of the shared log

Description

This field holds the name of the shared logfile the module is currently writing to.


Datafield NXTADD Timegap between checks

Description

This field defines the default maximum frequency of checking the filesize. The default value of 0.01, which stands for once per minute, is set in the init of LOGMOD.


Datafield SWTLST List of all hours where a switch should occur

Description

String to mark all hours with a nonspace character where a switch of the log should take place. The first character represents midnight or 0:00, the second 1:00 and so on.


Datafield MOVERRFLG Logfile move error

Codetable
Code Text
No error occurred
X Error occurred when moving logfile



Rules

Rule Name Additional
default LOGDSP\LOGFIL order 900
function InternalLogPrefix text
function SuspendLog text method
function WriteSummary text method
init
sub CheckLogAutoSwitch method
sub CloseLog method
sub CommitLog method
sub HandleInterruptTransactionZLOG method
sub InternalClearEvtEntry
sub InternalClearFlagCount
sub InternalClearLog
sub InternalCreateEvtEntry
sub InternalCreateLogFile
sub InternalStoreEvtData
sub InternalUpdateEvtEntry
sub InternalWriteLine
sub LnkLeaveActionLOGMOD method
sub LogModCloseLog method
sub LogModStartLog method
sub LogModWriteLine method
sub ResumeLog method
sub StartDefLog method
sub StartLog method
sub StartLogWithLateEvent method
sub StartSharedLog method
sub StartTrnLog method
sub SwitchLog method
sub WriteLine method
sub WriteLineAndStatus method



Rules Description and Comments

default LOGDSP\LOGFIL order 900

Rule to automatically set the currently created log as log to be displayed


function InternalLogPrefix : text

Function to build the lineprefix used to begin each line of a log.


function SuspendLog : text method

Function to temporarily suspend an open log.
Filename of the currently used logfile is returned.
This returned filename should be used as argument to the corresponding call to ResumeLog.
The intended usage is to suspend an open log to be able to write an entry to a shared log.
In this case the sequence should be
$LogFil = LOGMOD.SuspendLog
LOGMOD.StartSharedLog( “xxx” )
LOGMOD.WriteLine( “xyz was processed” )
LOGMOD.CloseLog( “” )
LOGMOD.ResumeLog( $LogFil )

Corresponding function: ResumeLog


function WriteSummary( in ArgHea text, in ArgFlg text ) : text method

Function to write the summary of the currently written log.
The function returns the most severe level. The internal used sequence is:
blank → `O`ther → `I`nfo → `W`arning → `E`rror

ArgHea may be used to set the heading of the Summary. If a blank heading
is passed a default heading is used.
ArgFlg Passing a nonblank value clears the counter after output of the summary.

Corresponding functions: StartLog, StartSharedLog, WriteLine, CloseLog


sub CheckLogAutoSwitch method

Routine to check for automatic switching of the log due to size overrun or timer.
This routine might be called externally. It is internally called when writing loglines.
The following externally set fields control the switching to a new logfile:
MAXSIZ describes the maximum allowed size of a logfile. (Default: 3 MB)
SWTLST holds a list of hourmarkers for time controlled switching (Default: No time)
NXTADD describes the maximum frequency of the automatically executed checks (Default: 0.01, thus check not more often than every minute)

Corresponding functions: SwitchLog


sub CloseLog( in ArgRtn text ) method

Routine to finally update and close a log. If the counter of marked lines are set, the
Summary is automatically created with the default heading.
ArgRtn might optionally hold a returncode used to update the event created on entry.
After having used this function a DBCommit has to be issued by the calling transaction.

Corresponding functions: StartLog, StartSharedLog, WriteLine, WriteSummary


sub CommitLog method

Routine to flag the current transaction as idle.
The intended usage is to call CommitLog after having complete a task when returning control to the user.
When using CommitLog at least one WriteLine should be executed before any data is amended.
After having completed the amendment and if necessary commited the amendments to the database
a call to CommitLog would flag the log as complete (up to now). Any further WriteLine would
restore the incomplete status.


sub HandleInterruptTransactionZLOG method

On execution of an Interrupt check and optionally close a log


sub InternalClearFlagCount

Routine to clear the counter per flag


sub InternalClearLog

Internal routine to initially clear all log fields


sub InternalCreateEvtEntry( in ArgRtn text )

Internal routine to create the EVT entry.


sub InternalCreateLogFile

Internal routine to create the filename of the processing log or the filename of an archive of
a shared logfile
Output is the created logfil with the filename stored in LOGFIL.


sub InternalStoreEvtData( in ArgRtn text )

Internal routine to save the fields of the EVT into the local EVT module
Has internally to be used after creation of the logfile.
Database related fields like INR and Session-INR should be set separately.


sub InternalUpdateEvtEntry( in ArgRtn text )

Routine to finally update the evt entry of a log.
ArgRtn might optionally hold a returncode used to update the event created on entry.
After having used this function a DBCommit has to be issued by the calling transaction.

Corresponding functions: CloseLog


sub InternalWriteLine( in ArgLin text, in ArgFlg text )

Part of the WriteLine routine to output the text into the logfile without switch checking.


sub LogModCloseLog( in ArgRtn text ) method

Routine to finally update and close a log.
ArgRtn might optionally hold a returncode used to update the event created on entry.
After having used this function a DBCommit has to be issued by the calling transaction.

This routine is obsolete and the new routine CloseLog should be used.


sub LogModStartLog( in ArgTxt text ) method

Procedure to initially create a Log.
If possible an event is created holding a textual reference to the created logfile.
ArgTxt holds the text used in the event to describe the action, that will take place.

This routine is obsolete and the new routine StartLog should be used.


sub LogModWriteLine( in ArgLin text ) method

Inserts a Logentry / Logline into the open Log. The Log has to be started with the StartLog procedure in advance.
If the passed Text hold more than one line only the first line is prefixed by the current date and time.
The other lines are indented with space characters.

This routine is obsolete and the new routine WriteLine should be used.


sub ResumeLog( in ArgFil text ) method

Function to resume a temporarily suspended open log.
The filename returned by the preceding SuspendLog should be used as argument.

Corresponding function: SuspendLog


sub StartDefLog method

Open a new log and write a default header for standard transactions


sub StartLog( in ArgTxt text ) method

Procedure to initially create a Log.
If possible an event is created holding a textual reference to the created logfile.
ArgTxt holds the text used in the event to describe the action, that will take place.

Corresponding functions: WriteLine, WriteSummary, CloseLog


sub StartLogWithLateEvent( in ArgTxt text ) method

Procedure to initially create a Log. The Event will be created upon closing of the
log. This is intended for routines like SYSDBA which initially create the necessary
database table.
The event is created holding a textual reference to the created logfile.
ArgTxt holds the text used in the event to describe the action, that will take place.

Corresponding functions: WriteLine, CloseLog


sub StartSharedLog( in ArgLog text ) method

Procedure to initially create or extend a shared Log.
ArgLog holds the Basename of the shared log to be filled. (Default value is the Transactionname)
Corresponding functions: WriteLine, WriteSummary, CloseLog


sub StartTrnLog( in ArgEnvFlg text, in ArgDbFlg text, in ArgEty text, in ArgEtg text ) method

Open a new log and write a header for standard transactions


sub SwitchLog( in ArgTxt text ) method

Routine to close the current log and continue in a new logfile
ArgTxt holds an optional text describing the reason for the switch of the log, which
if set is inserted at the end of the old log.


sub WriteLine( in ArgLin text, in ArgFlg text ) method

Inserts a Logentry / Logline into the open Log. The Log has to be started with the StartLog or StartSharedLog procedure in advance.
ArgLin holds the Text to stored in the log.
If the passed Text hold more than one line only the first line is prefixed by the current date and time.
The other lines are indented with space characters.
ArgFlg holds an optional Flag to mark the severity of the entry

Corresponding functions: StartLog, StartSharedLog, WriteLineAndStatus, WriteSummary, CloseLog


sub WriteLineAndStatus( in ArgLin text, in ArgFlg text ) method

Inserts a Logentry / Logline into the open log and shows the line in the statusline
The arguments are identical to the routine WriteLine.
ArgLin holds a line of text to be stored in the log.
ArgFlg holds an optional flag to mark the severity of the entry

Corresponding functions: WriteLine


Modules

Module class Instance Comment
LOGDSP LOGDSP
EVT EVT