project BLF > class tLogger > method LogDatabaseAccess

Description

Log an update in the log file.


Parameters


icLogEntryinputcharacterCharacter strig that needs to be written to the log file
ihBufferinputhandle


Internal usage


unused


program code (program1/tlogger.p)

if (viLoggerDebugLevel mod 16) > 7
then if vlStatelessMode
then do transaction on error undo, leave:
    viLogBusinessCodeDataCount = viLogBusinessCodeDataCount + 1.
    create tLogBusinessCodeData.
    assign tLogBusinessCodeData.tiCount  = viLogBusinessCodeDataCount
           tLogBusinessCodeData.tcMethod = "<DatabaseAccess>" + chr(10)
                                         + "time=" + string(now) + chr(10)
                                         + icLogEntry + chr(10).
    if ihBuffer <> ?
    and ihBuffer:type = "BUFFER":U
    then do:
        vcValue = string(ihBuffer:rowid) no-error.
        tLogBusinessCodeData.tcMethod = tLogBusinessCodeData.tcMethod + "rowid=" + vcValue + chr(10).
    end.
    tLogBusinessCodeData.tcMethod = tLogBusinessCodeData.tcMethod + "</DatabaseAccess>" + chr(10).
    release tLogBusinessCodeData.
end.
else if vcLogBusinessCodeFile <> ""
then do:
    output stream sLug to value(vcLogBusinessCodeFile) append.
    put stream sLug unformatted
        "<DatabaseAccess>" skip
        "time=" now skip
        icLogEntry skip.
    if ihBuffer <> ?
    and ihBuffer:type = "BUFFER":U
    then do:
        vcValue = string(ihBuffer:rowid) no-error.
        put stream sLug unformatted
            "rowid=" vcValue skip.
    end.
    put stream sLug unformatted
        "</DatabaseAccess>" skip(1).
    output stream sLug close.
end.

if (viLoggerDebugLevel mod 32) > 15
and ihBuffer <> ?
then do:
    output stream sLug to value(vcLogDatabaseAccessFile) append.
    put stream sLug unformatted replace(string(now),",":U,".":U) "," icLogEntry.
    if ihBuffer:type = "BUFFER":U
    then do viFcCount1 = 1 to ihBuffer:num-fields:
        vhField = ihBuffer:buffer-field(viFcCount1).
        if not (vhField:name begins "CustomShort":U or
                vhField:name begins "CustomCombo":U or
                vhField:name begins "CustomLong":U or
                vhField:name begins "CustomNote":U or
                vhField:name begins "CustomDate":U or
                vhField:name begins "CustomInteger":U or
                vhField:name begins "CustomDecimal":U or
                vhField:name = "tc_Rowid":U or
                vhField:name = "tc_ParentRowid":U or
                vhField:name = "tc_Status":U)
        then do:
            vcValue = "<NotAvailable>".
            vcValue = vhField:buffer-value no-error.
            /* remove characters that disrupt CSV formatting */
            vcValue = replace(vcValue,",":U,"<comma>":U).
            vcValue = replace(vcValue,chr(10),"<cr>":U).
            put stream sLug unformatted
                ",":U
                vhField:name
                "="
                vcValue.
        end.
    end.
    put stream sLug unformatted skip.
    output stream sLug close.
end.

if (viLoggerDebugLevel mod 64) > 31
and ihBuffer = ?
then do:
    viFcCount1 = index(icLogEntry,"Record count=").
    if viFcCount1 > 0
    then do:
        vcValue = substring(icLogEntry,viFcCount1 + 13,-1,"CHARACTER").
        vcValue = entry(1,vcValue,chr(10)).
        vcValue = entry(1,vcValue," ").
        viFcCount1 = 0.
        viFcCount1 = integer(vcValue) no-error.
        
        if icLogEntry begins "query "
        then vcValue = substring(entry(1,icLogEntry,chr(10)),6,-1,"CHARACTER").
        else vcValue = "".
        
        output stream sLug to value(vcLogUTIntermediateFile) append.
        if icLogEntry matches "*WHOLE-INDEX*"
        then put stream sLug unformatted "READ-WI " viFcCount1 vcValue skip.
        else put stream sLug unformatted "READ "    viFcCount1 vcValue skip.
        output stream sLug close.
    end.
end.