If you want to get a little more complicated, you could do this dance:
1. Write the script so that when it's run the first time, it rewrites the script node to define its name:
p.b = f'script_name = {p.h}\n' + p.b
2. Run the script using CTRL-B.
3. There has to be some code to check to see if script_name has been defined. If it is, the script would output your log message using its name. Otherwise, it outputs no nome.
4. When the script runs, it logs using the name if it was already defined.
This would let you use the same button for many different trees. OTOH, it does add more complication, so probably it's just easiest to embed the name directly.