Search code examples
intersystems-cacheintersystemsintersystems-ensemble

How do I reference a local method's name property in code?


I have a cache object property that I'd like to set to the current class and method in context's name, in order to do some tracking on what methods/classes are generating the largest frequency of these objects.

I can easily grab the current class' name using the code below, but am struggling to find a similar method for gathering the current method's name from the documentation.

set obj.ClassName  = ..%ClassName(1)  //Grab class name
set obj.MethodName =                  //Need to grab the method's name here

I know this can be easily accomplished when the method in question is setup as an object generator, but I'd rather not go down this route.. There has to be a simple way to reference the method's name, right?

///I'd rather not do this to my methods if I don't have to.
Method MyMethod() [ CodeMode = objectgenerator ]

Solution

  • There is a macro to do this: $$$CurrentMethod, defined within %occIO.inc, which you will find in %SYS so you don't need an include to use it. $$$CurrentClass is also defined there.