Search code examples
debuggingprogress-4glwebspeed

Preventing debug code going into production using Progress 4GL?


How would you prevent chunks of debugging code from accidentally leaking into production enviroment when using Progress 4GL?


Solution

  • A solution is based on the assumption that development enviroment has a unique propath entry that is not available in other enviroments and code is recompiled when moved over:

    &IF DEFINED(DEBUGGING) = 0 &THEN
        &IF PROPATH MATCHES '*development*' &THEN 
            &GLOBAL-DEFINE DEBUGGING TRUE
        &ELSE
            &GLOBAL-DEFINE DEBUGGING FALSE
            &MESSAGE Remove debugging: search for DEBUG within the code. 
        &ENDIF        
    &ENDIF                                
    
    &IF DEFINED(DEBUGGING_STARTED) = 0 &THEN
        &GLOBAL-DEFINE DEBUGGING_STARTED TRUE
        IF {&DEBUGGING} THEN
        DO:
    &ELSE
        END.
        &UNDEFINE DEBUGGING_STARTED
    &ENDIF
    

    Usage

    Save file as "debug" (without extension) to a directory pointed at by propath, then:

    {debug}
    
     /* some debugging code here */
    
    {debug/}