sys_trace.srf 979 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. $PBExportHeader$sys_trace.srf
  2. global type sys_trace from function_object
  3. end type
  4. forward prototypes
  5. global function integer sys_trace (string arg_msg)
  6. end prototypes
  7. global function integer sys_trace (string arg_msg);Int rslt = 1
  8. Integer li_FileNum
  9. IF NOT runtimeLog THEN
  10. return rslt
  11. END IF
  12. string ls_tmpPath
  13. long max_len
  14. ls_tmpPath = space(200)
  15. max_len = lena(ls_tmppath)
  16. max_len = GetTempPath(max_len, ref ls_tmpPath)
  17. ls_tmpPath = lefta(ls_tmpPath, max_len)
  18. li_FileNum = FileOpen(ls_tmpPath+"ljerp_log_"+String(Today(), 'yyyyMMdd')+".txt", &
  19. LineMode!, Write!, LockWrite!, Append!)
  20. IF li_FileNum < 0 THEN
  21. rslt = 0
  22. GOTO ext
  23. END IF
  24. string ls_userid
  25. ls_userid = publ_userid
  26. if isnull(ls_userid) then ls_userid = ''
  27. IF FileWriteEx(li_FileNum, String(Today(), 'yyyy-MM-dd') + ' ' + String(Now(), 'HH:mm:ss') + ': ' + ls_userid + " " + arg_msg) < 0 THEN
  28. rslt = 0
  29. GOTO ext
  30. END IF
  31. ext:
  32. IF li_FileNum > 0 THEN
  33. FileClose(li_FileNum)
  34. END IF
  35. RETURN rslt
  36. end function