31.3 apex.debug namespace

This namespace stores all debug functions of Oracle Application Express.

31.3.1 Log Level Constants

LOG_LEVEL

apex.debug.LOG_LEVEL = {
        OFF: 0,
        ERROR: 1,
        WARN: 2,
        INFO: 4,
        APP_TRACE: 6,
        ENGINE_TRACE: 9
    };

Table 31-2 LOG_LEVEL Descriptions

Value Description

OFF: 0

Logging is off.

ERROR: 1

Error logging level

WARN: 2

Warning logging level.

INFO: 4

Information logging level.

APP_TRACE: 6

Application tracing logging level.

ENGINE_TRACE: 9

Engine tracing logging level.

31.3.2 apex.debug.error

Log an error message. The error function always writes the error regardless of the log level from the server or set with apex.debug.setLevel. Messages are written using the browsers built-in console logging if available. If supported console.trace is called. Older browsers may not support the console object or all of its features.

Parameters

Table 31-3 Parameters for debug.error

Name Type Description

...*

any

Any number of parameters logged to the console.

Example 1

This example writes the message "Update Failed" to the console.

apex.debug.error("Update Failed"); 

Example 2

This example writes an exception message to the console.

apex.debug.error("Exception: ", ex); 

31.3.3 apex.debug.getLevel

Method that returns the debug log level. The debug log level is synchronized with hidden item "#pdebug".

Parameters

None

Returns

Returns logging level as an integer 1 to 9 or 0 to indicate debug logging is turned off.

Example

This example retrieves the logging level, prepends "Level" and logs to the console.

apex.debug.log("Level=", apex.debug.getLevel()); 

See Also:

"Log Level Constants" for return value meanings.

31.3.4 apex.debug.info

Log an informational message. Similar toapex.debug.message with the level set to INFO.

Parameters

Table 31-4 Parameters for debug.info

Name Type Description

...*

any

Any number of parameters logged to the console.

Example

This example prints an informational message to the console if the log level is INFO or greater.

apex.debug.info("Command successful"); 

31.3.5 apex.debug.log

Log a message. Similar to apex.debug.message with the level set to the highest level.

Parameters

Table 31-5 Parameters for debug.log

Name Type Description

...*

any

Any number of parameters logged to the console.

Example

This example gets the logging level and writes it to the console, regardless of the current logging level.

apex.debug.log("Level=", apex.debug.getLevel()); 

31.3.6 apex.debug.message

Log a message at the given debug log level. The log level set from the server or with apex.debug.setLevel controls if the message is actually written. If the set log level is >= pLevel then the message is written. Messages are written using the browsers built-in console logging if available. Older browsers may not support the console object or all of its features.

Parameters

Table 31-6 Parameters for debug.message

Name Type Description

pLevel

Number

A number from 1 to 9 where level 1 is most important and level 9 is least important. Can be one of the LOG_LEVEL constants. Any other value such as 0 will turn off debug logging.

...*

any

Any number of parameters logged to the console.

Example

This example writes the message "Testing" to the console if the logging level is greater than or equal to 7.

apex.debug.message(7,"Testing")); 

31.3.7 apex.debug.setLevel

Method that sets the debug log level. Log messages at or below the specified level are written to the console log. It is rarely necessary to call this function because the debug log level is synchronized with the hidden item #pdebug that comes from the server.

Parameters

Table 31-7 Parameters for debug.setlevel

Name Type Description

pLevel

Number

A number from 1 to 9 where level 1 is most important and level 9 is least important. Can be one of the LOG_LEVEL constants. Any other value such as 0 will turn off debug logging.

Example

This example sets the logging level to application tracing.

apex.debug.setLevel(apex.debug.LOG_LEVEL.APP_TRACE)); 

31.3.8 apex.debug.trace

Log a trace message. Similar to apex.debug.message with the level set to APP_TRACE.

Parameters

Table 31-8 Parameters for debug.trace

Name Type Description

...*

any

Any number of parameters logged to the console.

Example

This example writes a log message to the console if the debug log level is APP_TRACE or greater.

apex.debug.trace("Got click event: ", event); 

31.3.9 apex.debug.warn

Log a warning message. Similar to apex.debug.message with the level set to WARN.

Parameters

Table 31-9 Parameters for debug.warn

Name Type Description

...*

any

Any number of parameters logged to the console.

Example

This example writes a warning message to the console if the debug log level is WARN or greater.

apex.debug.warn("Empty string ignored");