# \[IGN-7976\]Get Name of Message Handler Programmatically

**URL:** <https://forum.inductiveautomation.com/t/ign-7976-get-name-of-message-handler-programmatically/75750>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [June 30, 2023, 2:31am UTC](https://forum.inductiveautomation.com/t/ign-7976-get-name-of-message-handler-programmatically/75750 "2023-06-30T02:31:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![WillMT10](https://avatars.discourse-cdn.com/v4/letter/w/7feea3/32.png) [@WillMT10](https://forum.inductiveautomation.com/u/WillMT10)\
**Post date:** [June 30, 2023, 2:31am UTC](https://forum.inductiveautomation.com/t/ign-7976-get-name-of-message-handler-programmatically/75750/1 "2023-06-30T02:31:36Z")

</div>

Is there any way to get the name/"message type" of the message handler from within its own script? I'd like to include the name in some custom logging and my aversion to having to manually edit the script constant to match the handler name is getting the better of me 😅

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 5, 2023, 9:51pm UTC](https://forum.inductiveautomation.com/t/ign-7976-get-name-of-message-handler-programmatically/75750/2 "2023-07-05T21:51:26Z")

</div>

No, this isn't directly possible. I wouldn't necessarily recommend going this route, but if you _really_ wanted to, you can peek at the stack and find the 'filename' we feed into the Jython interpreter, which includes the handler name, which you could parse:

```auto
def handleMessage(payload):
	import sys
	filename = sys._getframe().f_code.co_filename
	# ex: <MessageHandlerScript:projectName/handlerName >	

```

I'll make a note to consider adding the handler name to this somehow. It'd be nice.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 5, 2023, 10:37pm UTC](https://forum.inductiveautomation.com/t/ign-7976-get-name-of-message-handler-programmatically/75750/3 "2023-07-05T22:37:55Z")

</div>

Assign to ` __name__ ` before you compile and execute the function, perhaps?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 5, 2023, 10:51pm UTC](https://forum.inductiveautomation.com/t/ign-7976-get-name-of-message-handler-programmatically/75750/4 "2023-07-05T22:51:49Z")

</div>

We should really be doing that here and elsewhere, probably, yeah. Maybe I can roll this into the "make gateway event scripts proper extension functions" work I want to do in 8.3.
