[log4plsql] Context Configuration
Brought to you by:
gmoulard
From: log4plsql g. m. l. <log...@li...> - 2007-07-10 12:36:26
|
Hi, I've been looking at the internals of log4plsql to determine whether I can use some of the functionality in my own logging framework. In particular I've been looking at the context mechanism. First off I should explain that I'm actually a Java developer, so my question could well be the result of my crude understanding of plsql, but here goes anyway! Basically, each procedure maintains it's context information across many procedure calls. For example: create or replace package body test_logging IS pCTX PLOG.LOG_CTX := PLOG.init ('initApplication'); PROCEDURE test_1 IS BEGIN plog.setBeginSection(pCTX, 'test_1_section'); dbms_output.put_line('1 ' || pCTX.LSECTION); --output 1 test_2; dbms_output.put_line('2 ' || pCTX.LSECTION); --output 2 plog.setEndSection(pCTX, 'test_1_section'); END; PROCEDURE test_2 IS BEGIN plog.setBeginSection(pCTX, 'test_2_section'); --do some logging plog.setEndSection(pCTX, 'test_2_section'); END; END; >From this example both output 1 and output 2 are initApplication.test_1_section, which is what I would expect. My query is about how this is achieved. Looking at the mechanism, it seems that this is achieved with the use of pass by value semantics. But, looking at the context configuration methods, such as setBeginSection and setEndSection, these methods specify the NOCOPY parameter mode hint on the context parameter in an attempt to enforce pass by reference semantics on the context. This confused me. The behaviour I was seeing seemed to be the result of passing the context by value. Then I read that under certain circumstances the compiler may decide to silently ignore the NOCOPY hint, one of these being when the actual and formal parameters are record structures, which the config is. So, my questions are these, is the context mechanism meant to work through the use of pass by value semantics? If so, why does the context param defined with the NOCOPY parameter mode hint? And if not, how does the context mechanism work??? Cheers, Tony _________________________________________________________________ The next generation of Hotmail is here! http://www.newhotmail.co.uk |