NikWhitfield
asked on
Logging the current sub's name....
Hi,
I'm sure this comes up all the time. I would like to log errors / information and report the name of the sub / function from which they come. Is there any way to do this implicitely? Basically, I need a call which returns the current sub's name. Can it be done?
Cheers, Nik.
I'm sure this comes up all the time. I would like to log errors / information and report the name of the sub / function from which they come. Is there any way to do this implicitely? Basically, I need a call which returns the current sub's name. Can it be done?
Cheers, Nik.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi Nik
At the start of application open the log file using Open statement .
In each critical procedure<u want log>, use On Error goto ErrHandler
In err handler Use Print # method to log the error along with time etc:
'say number is 1 for LogFile
Exit Function
ErrHandler:
Print #1, Now & ": Function GetValue:" _
& Err.Descripotion
Hope it helps.
At the start of application open the log file using Open statement .
In each critical procedure<u want log>, use On Error goto ErrHandler
In err handler Use Print # method to log the error along with time etc:
'say number is 1 for LogFile
Exit Function
ErrHandler:
Print #1, Now & ": Function GetValue:" _
& Err.Descripotion
Hope it helps.
There is no built-in functionality for this.
The way to do this is to declare a global variable and set its value at the beginning of each procedure.
Ture Magnusson
Karlstad, Sweden