Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 378
  • Last Modified:

How to get the name of function or method name that is executing

I am doing some common logging within a large series of funtions and methods and was wondering if there is an easy way to determine the name of the current function/method while executing? Currently I set a const cTag = 'ThisFunction' at the beginning of the function/method and then use cTag in my common logging statements. I was curious if there is a better way to identify the function/method.
Thanks
0
softbreeze
Asked:
softbreeze
2 Solutions
 
jimyXCommented:
I believe your method is the only possible way to get the name of the executing function:

function ThisFunction():Datatype;
begin
  HoldThenameOfTheFunction:='ThisFunction';
...
end;

Simply because functions' names are not compiled into the exe program.
0
 
ThommyCommented:
The only way to achieve this, is to define a global variable which holds the name of the currently excuted function.

So there is no better way and your approach is definitely the right one...
0
 
Mohammed NasmanSoftware DeveloperCommented:
JclDebug unit has function called ProcByLevel, you can download it from JCL website
0
 
softbreezeAuthor Commented:
Thank you
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now