How to determine which included file my code is in

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?

Opus gets told when an error occurs which line it occurred on, and we can use that to work out which file the error's in. But I don't think there's any way to find out while the script is running which line is being executed.

1 Like

Ok, understood. Thanks anyway for the explanation!