DBAPPDEBUG and the debug level API

The DBAPPDEBUG environment variable sets the debug level of generated applications.

Valid values are:
  • 0 : nothing; debug turned off
  • 1 : error
  • 2 : error and warning
  • 3 : error, warning, and info
  • 4 or greater : error, warning, info and debug

By default, the environment sets for the dbapp templates set DBAPPDEBUG = 3, starting with dbapp5.0.

Debug level API functions

The debug level of generated applications can also be set or retrieved by API calls provided in the libdbappCore library. You can view the source by reading the source file libdbappCore.4gl. For more information on the dbapp libraries, go to Library files used by code events.

PUBLIC FUNCTION setLogLevel(p_level INTEGER)
The setLogLevel() function can set the trace level programmatically. It takes precedence over the DBAPPDEBUG environment variable.
When using the API, constants have been introduced for the log levels.
  • 0 : C_LOG_NONE
  • 1 : C_LOG_ERROR
  • 2 : C_LOG_WARNING
  • 3 : C_LOG_INFO
  • 4 : C_LOG_DEBUG
PUBLIC FUNCTION getLogLevel() RETURNS INTEGER
The getLogLevel() function can get the trace level programmatically.
PUBLIC FUNCTION log(p_level INTEGER, p_string STRING)
The log function displays a message (p_string) if the log level is on or below the passed-in level (p_level). Recall that the log level is set either by the DBAPPDEBUG environment variable or programatically by the setLogLevel() function.
The function takes two arguments:
  1. The p_level parameter specifies a log level.
  2. The p_string parameter specifies the message to display.
By default, BAM uses the log() function with the C_LOG_INFO log level in the generated shell for each code event.