Important alert: (current site time 7/16/2013 3:26:05 AM EDT)
 

winzip icon

Powerful & Flexible Application Logger & Error Handler

Email
Submitted on: 10/12/2000 12:36:32 AM
By: James Boyd 
Level: Intermediate
User Rating: By 17 Users
Compatibility: VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 27189
author picture
(About the author)
 
     This class, written by James Boyd, is a logger/error handler that does many things: 1.) Displays errors to users when they occur 2.) Records the activities of the application as various subroutines get executed 3.) When a run-time error happens, it can fire off an e-mail to the developer, replete with routine name, error description, and even a dump of the app's execution stack at that point 4.) It can also maintain a text file which has the application's execution stack history There are two ways of using this error handling/logging class: 1.) Use it just for error trapping 2.) Use it also for logging the execution path of an application. Since it captures the exact occurrence of a logged activity down to the THOUSANDTH of a second, it can be extremely useful for performing performance/efficiency analysis on subroutines.

 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :Powerful & Flexible Application Logger & Error Handler
'**************************************
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

10/12/2000 6:50:38 AMMaxW0lf

Rockin' code! 5 stars!
(If this comment was disrespectful, please report it.)

 
10/12/2000 5:25:12 PMRico

Very useful and well written too!
(If this comment was disrespectful, please report it.)

 
10/13/2000 3:58:06 AMWalther

Elegant coding, very useful !
(If this comment was disrespectful, please report it.)

 
10/13/2000 11:14:30 AMOlga

Good job , James.
Thank you !
(If this comment was disrespectful, please report it.)

 
10/14/2000 2:39:11 AMAndre

Great job, James but one problem
the email-prog (outlook) don't start up
a missing link..?
Can you help me ??
(If this comment was disrespectful, please report it.)

 
10/15/2000 11:33:25 PMLockwoodTech

Good code ... but the code doesn't consistently work with different long messages. I can send all of the pieces of one message in 100 char pieces but to send it at once it fails on 244th character. Coming from righ it fails on 176th. This should be tested on large strings to determine if certain characters, combination of characters or character + string length cause it to fail. Are there any other characters to trap for?
(If this comment was disrespectful, please report it.)

 
10/16/2000 11:12:28 PMLockwoodTech

thx James for reply (via email) - API isn't too robust but knowing limitations helps create a work-around. Test return code - if it is 2 (failure) slim down message and try again. James says rev 2 in the pipeline. 5 for effort.
(If this comment was disrespectful, please report it.)

 
11/26/2000 11:51:02 AMMike L

Excellent code, but as some others have reported the email program (Outlook Express in my case) fails to open up. Any fixes ? Thank you.
(If this comment was disrespectful, please report it.)

 
11/29/2000 1:13:23 AMPramono Jekti

The email program (Outlook 5 in my case) fails to open up because VB API "ShellExecute" return value 2 (mean ?).

Disable this command/line :
MessageBody = Replace(MessageBody, " ", "%20")
in function "Email_Erorr",
and abrakadabra.....the email program show up.

(If this comment was disrespectful, please report it.)

 
3/28/2001 2:32:31 PMDavid F

Great Code!!! Comes in very handy!!

Does anyone know about using Lotus
Notes to run the email portion of this
code? Any info would be greatly
appreciated.
(If this comment was disrespectful, please report it.)

 
6/4/2002 8:19:44 PMThomas Hannibal

When opening the default email-program using the Shell command you have to make sure that the email-body isn't too long. If it is too long the email program will not open!!! I don't know the reason for it. Maybe somebody else knows?!
(If this comment was disrespectful, please report it.)

 
6/19/2003 10:55:41 PM

I am using Outlook express 6, and it puts the WHOLE email body, subject, etc in the TO field..!
(If this comment was disrespectful, please report it.)

 
5/22/2004 5:24:19 PM

Very good code, just one point: on my computer the whole email is put in the TO field. To avoid that, simply put "?" between email address and subject instead of "&" if there are no CCs, and it works great !
(If this comment was disrespectful, please report it.)

 
4/22/2007 10:37:52 PMhd2000

May I know How to get application's execution stack history ? and which variables hold to it.
(If this comment was disrespectful, please report it.)

 
4/22/2007 11:16:53 PMhd2000

Could it automatically send email to the developer ?
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.