views:

66

answers:

3

Hi, I'd like to somehow find out which CFC is calling my method.

I have a logging CFC which is called by many different CFC's. On this logging CFC there's a need to store which CFC called for the log.

Whilst I could simply pass the CFC name as an argument to my log.cfc, I find this to be a repetitive task, that might not be necessary, if I somehow could find out "who's" calling the method on log.cfc

Is there any programmatic way of achieving this?

Thanks in advance

+1  A: 

One kludgey way is to throw/catch a custom error and parse the stack trace. Here are some examples

Al Everett
A: 

I don't know of a method to do directly what you are asking, maybe someone else does.

However, I believe you could get the stack trace and create a function to parse the last method call.

This function on cflib will get you the stack trace.

derivation