Re: Coding practice for better user-proofing

new topic     » goto parent     » topic index » view thread      » older message » newer message
fizzpopsoft said...

Is there a more elegant way to create/use a user debug level..?
BTW, debug level > 2 is only available when sanctioned by myself.

Hello Alan,

One upon a time, I used a function I called logMsg using a variable named debug_level.

public integer  debugLevel = 0   -- 0=no debug, 1=debug file only, 2=debug_file and screen output 
 
------------------------------------------------------------------------------ 
 
public function dateStamp(sequence msg) 
-- prefixes the message by date and time for logging 
  sequence cur_date 
 
  cur_date = date() 
  return sprintf("%d-%02d-%02d %02d:%02d:%02d -> %s\n", { 
                             (cur_date[1] + 1900), cur_date[2], cur_date[3], 
                              cur_date[4], cur_date[5], cur_date[6], msg 
                            }) 
end function 
 
------------------------------------------------------------------------------ 
 
public procedure logMsg(sequence msg) 
-- records logs 
  if debugLevel>0 then 
    puts(f_debug, dateStamp(msg)) 
    flush(f_debug) 
  end if 
  if debugLevel>1 then 
    puts(1, dateStamp(msg)) 
  end if 
end procedure 
 

Regards

Jean-Marc

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu