Class question
Posted: Wed Oct 15, 2003 1:16 pm
Hello,
I have a question regarding classes. I have a set of classes for doing most of my tasks. They work great. What I also have is a class for logging errors. Each class gets a copy of this error routine. Basically, I declare a single instance and then add it to each active instance of the other classes.
For example, I have a the following classes: players, characters and monsters. Each class has a reference to errorlogger. errorlogger has a single function called logerror($message).
Each class also has a function called "adderrorlogger(&$errorlogger)" to ensure that they are getting a reference fo the errorlogger class.
My question, after that log explanation, is how can I determine which class called the errorlogger->logerror($message) function from with the logerror function.
Basically, I want the logger to determine who called it so it can also log which class through the error. Because it's not inherited I can't use get_parent_class();
The concept goes a little beyond what I have stated above but that's the simplified version.
Any ideas?
I have a question regarding classes. I have a set of classes for doing most of my tasks. They work great. What I also have is a class for logging errors. Each class gets a copy of this error routine. Basically, I declare a single instance and then add it to each active instance of the other classes.
For example, I have a the following classes: players, characters and monsters. Each class has a reference to errorlogger. errorlogger has a single function called logerror($message).
Each class also has a function called "adderrorlogger(&$errorlogger)" to ensure that they are getting a reference fo the errorlogger class.
My question, after that log explanation, is how can I determine which class called the errorlogger->logerror($message) function from with the logerror function.
Basically, I want the logger to determine who called it so it can also log which class through the error. Because it's not inherited I can't use get_parent_class();
The concept goes a little beyond what I have stated above but that's the simplified version.
Any ideas?