HGeneAnthony Posted September 14, 2008 Share Posted September 14, 2008 I'm creating a logging class and I'd like to record the function name where an error was logged, as well as line number, file name, etc. I know I can pass the details __LINE__, __FILE__, __FUNCTION__, __CLASS__, as arguments to a function but this is a pain in the ass to do this for every error and it makes the code look sloppy. I would like to just put these details in the error function so I can keep it clean, however this will put in the current function details not the calling function so I was wondering is there a way to do this? Link to comment https://forums.phpfreaks.com/topic/124153-can-i-grab-the-details-of-a-calling-function-file-name-function-name-etc/ Share on other sites More sharing options...
Mchl Posted September 14, 2008 Share Posted September 14, 2008 Pass them as parameters? Link to comment https://forums.phpfreaks.com/topic/124153-can-i-grab-the-details-of-a-calling-function-file-name-function-name-etc/#findComment-640982 Share on other sites More sharing options...
HGeneAnthony Posted September 14, 2008 Author Share Posted September 14, 2008 I meant arguments. I don't want to have to pass the __LINE__, __FILE__, __CLASS__, etc. each time I call a log or error. I would just like to use a log function and have it grab the data of the function that called it. Link to comment https://forums.phpfreaks.com/topic/124153-can-i-grab-the-details-of-a-calling-function-file-name-function-name-etc/#findComment-641260 Share on other sites More sharing options...
Mchl Posted September 14, 2008 Share Posted September 14, 2008 Maybe debug_backtrace() function? Link to comment https://forums.phpfreaks.com/topic/124153-can-i-grab-the-details-of-a-calling-function-file-name-function-name-etc/#findComment-641272 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.