I have a script file that includes multiple other files.
At runtime I can use Script.file
or use a global variable like SCRIPT_NAME
to find out which script file I'm in (for logging/debugging purposes). Plus the information is automatically prefixed to any log output.
Is it somehow possible to find out which of the original included files I'm currently in? Script.file
doesn't help; it gives me the main script's file. Using a global variable like INCLUDE_SCRIPT_NAME
in each of the included files doesn't work either because it's overwritten by each subsequent file and the last one "wins".
Yes, of course I can add this information manually to each occurrence of my debug statements, but I'm lazy and I make mistakes... The information is obviously available since it's part of DO's log statement if an error occurs - but can I access it somehow?