Advanced Search
HomeTechnical DocumentsTipsTivoliEnterprise Console › TEC Rule Tracing (Part 1)

TEC Rule Tracing

Tracing is an invaluable aid when developing or troubleshooting rulebases. Unfortunately in an environment where you're sharing the development load, or you have many background events arriving, searching through the trace log can be a lengthy process and often quite frustrating. The problem with tracing is that you have to restart the rulebase if you want to change the tracing mode, and the tracing happens for every rule.

This weeks tip describes how you can generate your own trace messages that will appear in the trace log.

Generate your own Trace Information

It is possible to generate you own trace or debug information within your rules. To do this first you need to create your own tracing template, something like this should suffice:-

Open in New Window
ruleinitialise:
(
    
event_event of_class 'TEC_Start'
        
where [ ],

    
actiondefine_assertions:
    (
        
assert((my_trace(_msg) :-

            
/* Check current status */
            
recorded(recordingdebugger_status),

            
/* If it's on, then we'll write a message */
            
_status == 'on',

            
/* get the filehandle for the trace file */
            
recorded(trace_filedebugger_F),
            
fprintf(_F'---->> %s\n'_msg);

            
/* Else we won't - but never fail */
            true
        ))
    )
).?>

Now within our rule actions we can simply add the statement like the following:

Open in New Window
action:
(
    
_status == 'OPEN',
    
my_trace("The event was OPEN"),
    ....
    ....
),

action:
(
    
_status == 'CLOSED',
    
my_trace('The event was CLOSED'),
    ....
    ....
).
?>

The second part (next week) of this three part tip I will show you how you can turn tracing on and off dynamically without having to restart the Event Server.