project BLF > class ComponentPool > method SetDebugLevelInPool

Description

activate or deactivate business logging


Parameters


iiDebugLevelinputinteger
iiSessionIdinputintegersession ID will be part of the log file name.
ilStatelessModeinputlogical


Internal usage


unused


program code (program1/componentpool.p)

if ilStatelessMode
then vlStatelesModeInPool = yes.

if iiDebugLevel <> viDebugLevel
then do:
    assign viDebugLevel = iiDebugLevel.
    
    if viDebugLevel = 0
    then do:
        if vhLoggerInPool <> ?
        then do:
            /* write any remaining logs */
            vhFcComponent = vhLoggerInPool.
            <M-24 run LogUnitTest  () in tLogger>

            unsubscribe procedure vhLoggerInPool to "Logging.BusinessCode":U.
            unsubscribe procedure vhLoggerInPool to "Logging.DatabaseAccess":U.
            unsubscribe procedure vhLoggerInPool to "Logging.CreateInstance":U.
            unsubscribe procedure vhLoggerInPool to "Logging.DeleteInstance":U.
            run gipr_DeleteProcedure in vhLoggerInPool.
            delete procedure vhLoggerInPool.
            vhLoggerInPool = ?.
        end.
    end.
    else do:
        <M-3 run StartLoggerInPool  (output vhFcComponent (ohLogger)) in ComponentPool>
        
        if viDebugLevel mod 2 > 0   /* bit 1 */
        or viDebugLevel mod 4 > 1   /* bit 2 */
        then   subscribe procedure vhFcComponent to "Logging.BusinessCode":U anywhere run-procedure "LogBusinessCode":U.
        else unsubscribe procedure vhFcComponent to "Logging.BusinessCode":U.
        
        if viDebugLevel mod 16 > 7   /* bit 8 */
        or viDebugLevel mod 32 > 15  /* bit 16 */
        or viDebugLevel mod 64 > 31  /* bit 32 */
        then   subscribe procedure vhFcComponent to "Logging.DatabaseAccess":U anywhere run-procedure "LogDatabaseAccess":U.
        else unsubscribe procedure vhFcComponent to "Logging.DatabaseAccess":U.
        
        if viDebugLevel mod 64 > 31  /* bit 32 */
        then do:
            subscribe procedure vhFcComponent to "Logging.CreateInstance":U anywhere run-procedure "LogCreateInstance":U.
            subscribe procedure vhFcComponent to "Logging.DeleteInstance":U anywhere run-procedure "LogDeleteInstance":U.
        end.
        else do:
            unsubscribe procedure vhFcComponent to "Logging.CreateInstance":U.
            unsubscribe procedure vhFcComponent to "Logging.DeleteInstance":U.
        end.
        
        if vlStatelesModeInPool
        then do:
            <M-4 run SetStatelessMode  () in tLogger>
        end.
        
        <M-2 run SetDebugLevel
           (input  viDebugLevel (iiDebugLevel), 
            input  iiSessionId (iiSessionId)) in tLogger>
    end.

    SETcontext: do:
    
        vcWorkContext = session:server-connection-context.
        do viFcCount1 = num-entries(vcWorkContext) to 1 by -1:
            if entry(viFcCount1,vcWorkContext) = "MultiSession"
            then leave SETcontext.
        end.
        
        do viFcCount1 = num-entries(vcWorkContext) to 1 by -1:
            if entry(viFcCount1,vcWorkContext) begins "DebugLevel=":U
            then leave.
        end.
        if viFcCount1 = 0
        then if viDebugLevel > 0
             then vcWorkContext = vcWorkContext + ",DebugLevel=" + string(viDebugLevel).
             else.
        else if viDebugLevel = 0
             then entry(viFcCount1,vcWorkContext) =  "".
             else entry(viFcCount1,vcWorkContext) = "DebugLevel=" + string(viDebugLevel).
        
        do viFcCount1 = num-entries(vcWorkContext) to 1 by -1:
            if entry(viFcCount1,vcWorkContext) begins "DebugLevelSession=":U
            then leave.
        end.
        if viFcCount1 = 0
        then if viDebugLevel > 0
             then vcWorkContext = vcWorkContext + ",DebugLevelSession=" + string(iiSessionId).
             else.
        else if viDebugLevel = 0
             then entry(viFcCount1,vcWorkContext) =  "".
             else entry(viFcCount1,vcWorkContext) = "DebugLevelSession=" + string(iiSessionId).
        
        vcWorkContext = trim (vcWorkContext,",").
        if session:server-connection-context <> vcWorkContext
        then session:server-connection-context = vcWorkContext.
    end.
end.