Databases Reference
In-Depth Information
You have to be careful about your usage of the LOG_MESSAGE procedure, though. For instance,
injecting a LOG_MESSAGE call in the middle of the loop would first create a huge number of log entries
that you would be unlikely to want to wade through, and second, would potentially impact performance
as you would be executing the full code path of the LOG_MESSAGE procedure 10,000 times.
That is where the p_level parameter comes in handy. Consider Listing 6-3. Here we've done exactly
what was just warned against, but notice that the value for the level of the outer calls is at a higher level
than that of the inner calls.
Listing 6-3. Using P_LEVEL to designate the message level
BEGIN
--
APEX DEBUG MESSAGE.LOG MESSAGE( P MESSAGE =>'START - INSERTING 10000 RECORDS...', P LEVEL=>5);
--
FOR I IN 1..10000 LOOP
--
APEX DEBUG MESSAGE.LOG MESSAGE( P MESSAGE =>'START RECORD '||I, P LEVEL=>7);
--
INSERT INTO PERF TEST (guid1, guid2, guid3, created on)
VALUES (SYS GUID, SYS GUID, SYS GUID, SYSDATE);
--
APEX DEBUG MESSAGE.LOG MESSAGE( P MESSAGE =>'END RECORD '||I, P LEVEL=>7);
--
END LOOP;
--
APEX DEBUG MESSAGE.LOG MESSAGE( P MESSAGE =>'END - INSERTING 10000 RECORDS...', P LEVEL=>5);
--
END;
Now when we choose to enable debugging programmatically, we can use the p_level parameter to
decide to what level of message we wish to log. Calling ENABLE_DEBUG_MESSAGES with p_level set to
5 would only log the messages outside the loop. However, enabling debug with a message level of 7
would log both outside and inside the loop. Using this mechanism you can manage the level at which
messages are logged and what level of log message you wish to capture.
Caution Using Interactive Debugging from either the Developer Toolbar, or by manipulating the URL will always
initiate logging to capture messages level 7 and above.
Lastly, using the p_enabled parameter of LOG_MESSAGE allows you to dictate that a message is
important enough to always be logged, whether or not debugging has been enabled. Listing 6.4 shows
the same code but injects a LOG_MESSAGE call in the top of the block that will always be written to the
APEX Dictionary, regardless of the state of debugging.
Search WWH ::




Custom Search