Source language: Translate to:

Error logging & sending to Support - Automation Code Kit

NeoBook tips, tricks, code samples and more...

Moderator: Neosoft Support

Error logging & sending to Support - Automation Code Kit

Postby Jerry » Wed Aug 18, 2004 3:22 pm

For debugging purposes I created a couple of code snippets that build log file of application errors on user's computer and send it with some system info to You.
(Don’t expect much, it’s from beginner for beginners. ;)

1a)  ERROR LOG FILE, build from Timer on MasterPage.  It’s important that this file resist re-installation of MyApp  because the first what user do on problems is to reinstall the program and error log file would be away (easy to configure in Qsetup from pantaray.com, an excellent setup program, almost as NB :) .

.Timer hidden on MasterPage that checks error messages and save them in error log file.
SetVar "[DateText]" "[DateShort] [#9][Time24]"
If "[LastError]" "<>" ""
  FileWrite "[PubDir]Errors.txt" "Append" "[DateText][#9]Error>[#9][LastError][#9]on Page:[#9][LastPage]"
  SetVar "[LastError]" ""
EndIf
.Next lines are not necessary if You don’t use DB PlugIn
If "[dbfError]" "<>" ""
FileWrite "[PubDir]Errors.txt" "Append" "[DateText][#9]dbfError>[#9][dbfError][#9]on Page:[#9][LastPage]"
  SetVar "[dbfError]" ""
EndIf

1b)  TimerStarter at BookProperties/Actions/StartUp, it also writes logon time

.Start Timer (on MasterPage) that checks for error messages each 10 sec and save them in Errors.txt
SetVar "[DateText]" "[DateShort] [#9][Time24]> [#9]LogOn"
FileWrite "[PubDir]Errors.txt" "Append" "[DateText]"
TimerStart "Timer1" "10000"

1c)  BookProperties/Actions/ShutDown,  writes log off time

SetVar "[DateText]" "[DateShort] [#9][Time24]> [#9]LogOff"
FileWrite "[PubDir]Errors.txt" "Append" "[DateText]"

2)  SYSTEM INFO FILE at BookProperties/Actions/StartUp, is build each time MyApp starts

.Write System.txt file for Debug purposes
FileErase "[PubDir]System.txt"
FileWrite "[PubDir]System.txt" "Append" "'[AppName]' on [DateShort] at [LogInName]"
FileWrite "[PubDir]System.txt" "Append" " "
FileWrite "[PubDir]System.txt" "Append" "ProgrammVersion: [#9][Ver]"
FileWrite "[PubDir]System.txt" "Append" "WindowsVersion: [#9][WindowsVer]"
FileWrite "[PubDir]System.txt" "Append" "NeoBookVersion: [#9][NeoBookVersion]"
FileWrite "[PubDir]System.txt" "Append" "PubDir: [#9][#9][PubDir]"

3)  Action on Button that sends Email in SendMail Form

SendMail "[Support]" "[Email]" "[Subject]" "[Body]" "[PubDir]Errors.txt|[PubDir]System.txt"

4)  Action on each PageProperties / PageEnter.  So it is possible to locate on which page error occurred.   (LastError is checked each 10 secs, it means it is possible, that user is already gone from this page, but unlikely in my static application.     For some quick-action applications” might be necessary to increase checking frequency.

setvar "[LastPage]" “[PageTitle]”

5)  Sample of error log:
19.8.2004    20:08:59   Error>   Unable to connect to email host: test.nix.at   on Page:   Info

Hope it helps. If someone need, I can post a Forms too (they are ObjectGroups for CustomWindows) for putting 1. SMTPServer, UserName & PW, and 2. Email Information, From, To, Body & Attachments.  (Of course, only if it is allowed to post it here, the code of for this is quite long.)

If someone has nicer solution, please post.
Jerry



(Edited by Jerry at 2:54 am on Aug. 19, 2004)
Jerry
 

Error logging & sending to Support

Postby Wrangler » Wed Aug 18, 2004 8:05 pm

Nice contribution, Jerry. Thanks.

You might want to post this code and your longer code here:

http://www.software-zone.com/neosoft/index.php

Also a good place to upload sample pubs.



(Edited by Wrangler at 8:14 pm on Aug. 18, 2004)
Wrangler
 


Return to NeoBook Knowledgebase

Who is online

Users browsing this forum: No registered users and 1 guest