Is is possible to detect what file and line from which a function was called?

17 views
Skip to first unread message

Trevor Vaughan

unread,
Nov 11, 2015, 1:32:21 PM11/11/15
to puppe...@googlegroups.com
Hoping to use this for logging purposes.

I can get it from a custom type, but I don't seem to be able to snag this information from a function.

Thanks,

Trevor

--
Trevor Vaughan
Vice President, Onyx Point, Inc
(410) 541-6699

-- This account not approved for unencrypted proprietary information --

Trevor Vaughan

unread,
Nov 12, 2015, 9:20:46 AM11/12/15
to puppe...@googlegroups.com
All,

Please disregard, the answer is source.file and source.line and works MUCH better if you're not testing a function outside of a manifest set ;-).

Thanks,

Trevor

Henrik Lindberg

unread,
Nov 16, 2015, 4:22:32 PM11/16/15
to puppe...@googlegroups.com
On 2015-12-11 6:20, Trevor Vaughan wrote:
> All,
>
> Please disregard, the answer is source.file and source.line and works
> MUCH better if you're not testing a function outside of a manifest set ;-).
>
> Thanks,
>
> Trevor
>
That is not the same as where a function is called from, it is container
from which the evaluated code makes a call from.

For 4.x we have a ticket to make calling location available.

Question is: for what purpose is this needed? For errors? or for other
purposes?

- henrik

> On Wed, Nov 11, 2015 at 1:32 PM, Trevor Vaughan <tvau...@onyxpoint.com
> <mailto:tvau...@onyxpoint.com>> wrote:
>
> Hoping to use this for logging purposes.
>
> I can get it from a custom type, but I don't seem to be able to snag
> this information from a function.
>
> Thanks,
>
> Trevor
>
> --
> Trevor Vaughan
> Vice President, Onyx Point, Inc
> (410) 541-6699 <tel:%28410%29%20541-6699>
>
> -- This account not approved for unencrypted proprietary information --
>
>
>
>
> --
> Trevor Vaughan
> Vice President, Onyx Point, Inc
> (410) 541-6699
>
> -- This account not approved for unencrypted proprietary information --
>
> --
> You received this message because you are subscribed to the Google
> Groups "Puppet Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to puppet-dev+...@googlegroups.com
> <mailto:puppet-dev+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-dev/CANs%2BFoUh-R0sh%3DsCSaNx8hPQrz%2BxHepu%3DDCuQqp4ggtoYzLQKQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/puppet-dev/CANs%2BFoUh-R0sh%3DsCSaNx8hPQrz%2BxHepu%3DDCuQqp4ggtoYzLQKQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.


--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

Erik Dalén

unread,
Nov 16, 2015, 5:06:26 PM11/16/15
to puppe...@googlegroups.com

Using it for filling in file names and line numbers in the resources created by a function (like create_resources) seems like a good use case.


To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/n2dhe9%24poe%241%40ger.gmane.org.

Trevor Vaughan

unread,
Nov 17, 2015, 10:22:16 AM11/17/15
to puppe...@googlegroups.com
That is the main use case, yes.

I would love to be able to add some extra data to my debug messages to help people along the way. This would prevent my debugging from needing to deliberately fail to figure out where things are going wrong.

Thanks,

Trevor


For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages