line number in cfoutput

51 views
Skip to first unread message

Stéphane MERLE

unread,
Apr 13, 2016, 8:07:40 AM4/13/16
to Lucee
Hi,

in order to add some debug information in my cfml app in lucee, I would like to add the line number in my dump ... but I cannot find any variable containing it :

<cfif ARGUMENTS.DEBUG><cflog file="debug" text="I am at line 61"></cfif>

am I missing something here ?

Stéphane



Mark Drew

unread,
Apr 13, 2016, 8:28:44 AM4/13/16
to lu...@googlegroups.com
You could throw and catch the error which will give you both a stack trace and a line number. 

Mark Drew
- Sent by typing with my thumbs. 
--
Love Lucee? Become a supporter and be part of the Lucee project today! - http://lucee.org/supporters/become-a-supporter.html
---
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/2c2d5d50-2fed-4e1f-ba77-b2afd4d7ae70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stéphane MERLE

unread,
Apr 13, 2016, 9:00:21 AM4/13/16
to Lucee
but ... there is no error, I just want to add some debug to my logfile with line number ...

I can add it statically but each change in the source code would imply correcting the data

Mark Drew

unread,
Apr 13, 2016, 9:10:24 AM4/13/16
to lucee
Actually, you don’t need to throw an error, you could get the information you want from: http://docs.lucee.org/reference/functions/callstackget.html

This will give you an array of items so you can get the info from that:
<cfscript>


    one();
        function one(){
            two();
        }

        function two(){
            three();
        }


        function three(){
            var stack= callStackGet();
            log file="debug" text="I am at line #stack[1].lineNumber#";
        }
</cfscript>


Gert Franz

unread,
Apr 13, 2016, 9:28:35 AM4/13/16
to lu...@googlegroups.com
Have a look at the function getCurrentContext() that gives you what you're looking for...

Gert

Sent from somewhere on the road

Mark Drew

unread,
Apr 13, 2016, 9:32:06 AM4/13/16
to lucee
“this function is deprecated, use function CallStackGet instead.”

:D

MD

Stéphane MERLE

unread,
Apr 13, 2016, 9:32:11 AM4/13/16
to Lucee
seems to be deprecated for CallStackGet

I will manage with it.

Thanks so much !

Stéphane

Gert Franz

unread,
Apr 18, 2016, 5:39:35 AM4/18/16
to lu...@googlegroups.com

Well, that explains some logs I get J

 

Thanks Mark

 

Sincerely
Gert Franz

 

RASIA GmbH

Spittelgasse 7

5103 Moeriken-Wildegg

Switzerland

Email: ge...@rasia.ch
Skype: gert.franz

Phone Switzerland: +41 76 5680 231

--

Love Lucee? Become a supporter and be part of the Lucee project today! - http://lucee.org/supporters/become-a-supporter.html
---
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.

image001.png
Reply all
Reply to author
Forward
0 new messages