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


History

VersionStatusNotes
10.2NewNew in this version.