Reference a Gateway script name within the script

This is probably very simple, but I could not find any reference to it in the forums. I have a gateway script running and would like to create a logger for the script based on the gateway script name. Instead of hard coding the script name, can I get the name from some property?

any help is appreciated.
Thanks

The builtin __name__ should work; you can also try logging the result of dir() (you may need to wrap it as a string) to introspect the namespace available for your script at execution time.

Thanks for the reply, the name variable did not give me the name of the script. It just gave me “main”. Also, not sure what to do with the dir() command.

The __name__ variable will only be valid at the top level of a script module, not an event script. The dir() function yields a list of names in scope in which it is called, or if given an object, the list of property names for that object. You can convert that list to a string and log it, reviewing the result in your gateway log.

Can you import/export that list somehow, by the way?