zlogalways
zlogalways
FORMULA

The zlogalways statement unconditionally outputs a message to the instrumentation log.

Parameters

This statement has one parameter:

formula – message to output to log.

Description

This statement unconditionally outputs a message to the instrumentation log. This is useful in code that isn’t in a named procedure, for example code in an execute statement or in a starttimer statement. Since the Instrumentation panel doesn’t recognize code that isn’t in a named procedure, you can’t enable coverage for that code, which means that you can’t use the regular zlog statement in that situation.

Since the zlogalways statement is always enabled, you can use it in any code, not just in a named procedure. You can combine this with the zlogging( function so that the message is only sent to the log if the procedure where the code is defined has instrumentation coverage enabled. For example, suppose you have a procedure named Select Same Name that contains this code for selecting all records with the same name as the current name.

    let selectFormula = {Name = }+quoted(Name)
    execute ?(zlogging(),{zlogalways "Run selection"},{})+"select "+selectFormula

In this example, the zlogalways statement will only be executed if log coverage for the Select Same Name statement is enabled (see Debug Instrumentation.

The example above is rather contrived, in this case it would be simpler to use a regular zlog statement on the line above the execute statement and avoid all of the extra complication. But if you wanted to display an intermediate value generated in the execute code, this will allow you to do it.

Here is a more practical application. This code opens the named object First Name on the current form for editing, but before it does, it starts a timer that will stop the editing after 20 seconds (if it hasn’t been stopped already). When the timer fires after a 20 second delay, it will send a message to the log (if the log for the procedure below is enabled).

    let timeout = 20
    zlog "Start "+labelize(timeout)
    starttimer "_NoUserActivity",
        "code",
            ?(zlogging(),
                {zlogalways "[_NoUserActivity] Editing of First Name stopped."},"")+
            {if info("activeobject")<>"" closeactiveobject endif},
        "repeat",1,
        "next",supernow()+timeout
    objectaction "First Name","Open"

Note that the message above has the prefix `[_NoUserActivity]` coded into the formula. Unlike the zlog statement, zlogalways does not add a prefix of the procedure name to the message – it can’t, because there may not be any procedure name! So if you want a prefix, you must add it yourself.

See Also

- Client/Server Debug Instrumentation -- using instrumentation with Panorama X server and clients.
- Coding with Debug Instrumentation -- modifying your code to generate debug instrumentation output.
- Crash Proof Debug Instrumentation Monitoring -- real time crash-proof instrumentation monitoring
- Customizing Debug Instrumentation Coverage -- specifying what code is being debugged at the moment.
- Debug Instrumentation -- conditional logging of the internal state of Panorama program code.
- Debug Instrumentation Log Window -- dynamically monitor debug instrumentation output as your program runs.
- Debug Instrumentation Monitoring using an External Program -- monitoring debug instrumentation with an external program (Terminal.app, BBEdit.app).
- Debug Instrumentation Text File -- configuring and accessing the debug instrumentation log (text) file.
- info("runningunderterminal") -- returns the name of the terminal program if Panorama was launched under one, otherwise it returns empty text.
- labelize( -- returns the value of a field or variable along with a label. This saves typing when you need to display fields or variables when logging and debugging.
- labelizeformula( -- returns the value of a formula along with the formula itself as a label.
- labelizeinfo( -- returns the value of an info( function, along with the function itself as a label.
- labelizepattern( -- formats a text value using a label and a pattern.
- Recording Code Triggers in Debug Instrumentation -- the code triggers option automatically tracks whenever any code is triggered, whether from a menu, a button, or implicitly (for example when data is entered).
- Recording Control Flow in Debug Instrumentation -- configure debug instrumentation to automatically log when control flow is non-linear, for example a call, return, goto, etc.
- setzlog -- turns instrumentation coverage on or off for a specific procedure (or all procedures within a database).
- zlog -- outputs a message to the instrumentation log (if instrumentation is enabled).
- zlogcoverage -- allows instrumentation coverage to be turned on or off within a procedure.
- zlogdictionary -- outputs a data dictionary to the instrumentation log (if instrumentation is enabled).
- zlogging( -- returns true if zlogging is enabled for the current database and procedure, otherwise false.

History

Version | Status | Notes
10.2 | New | New in this version.