Is there a way to override a built in tag in Lucee...
# lucee
s
Is there a way to override a built in tag in Lucee? I'd like to have Lucee log the file & line number of <cfabort/> when encountered. We have some cfaborts somewhere that are sometimes getting triggered and I don't know where they are.
z
lucee debugging logs cfabort with line numbers
my performance analyzer even has a report
p
CTRL+F your codebase?!
s
@Patrick Yes Ctrl+F will find cfaborts in my codebase. And that may be the route I end up taking - a huge commit across many many files adding logging near the cfabort tag so we can find which one is causing an occasional blank page. But I thought there might be an easier way.
p
Just seems like the fastest route if you can determine where you are blanking out then you can easily back trace the route to what might be causing, if it is a cfabort.
s
@zackster you are talking about the debugging data you can see at the bottom of the page, right? This problem only happens on production (we've had trouble reproducing it on dev, it only happens in rare circumstances) so that on-page debugging will not help. But if I could log that to a file, that would help. But I don't see how to do that in the Lucee debug settings.
j
@stillnet vscode has a
find in files
function in the edit menu. Free download if you don't use it. Just open the root folder and you should be set.
s
thanks @John Wilson, I do use VS code and I use Find in Files a lot. There are hundreds of cfaborts in our code across many files. What I would like to do is have them all report where they are happening (i.e. a log file that shows file name and line number of the cfabort when it's executed) so I can track down which ones are executing on production and giving users a blank page.
Currently you can set some tag attributes globally in application.cfc.
this.tag.log.application="true";
It would be cool if I could overwrite the whole tag in application.cfc. Something like:
this.tag.abort = function() {
writeLog("cfabort called from #callStackGet()[2].template#:#callStackGet()[2].lineNumber#");
super.abort();
}
d
@stillnet You can override a BIF with your own code. We've done this to fix a bug in the <cflocation /> tag. If you follow the Lucee 5 - Extensions documentation and just name your custom tag "Abort.cfc", it should override the BIF function. For our Location.cfc tag, I used the Lucee's source code as a starting point and then converted the code to CFML.
In your case, you could probably just proxy the calls to the native Lucee code that implements the Abort tag, but just add some logging before calling the abort.
👍 1
z
we have added logging with cflocation and cfhttp to trace.log, when trace is set to info, this is all logged out, we should add that for abort too https://luceeserver.atlassian.net/browse/LDEV-4272
blank pages can also come from functions when bufferring is disabled
but don't you know which urls are triggering a blank page?
if not, depending on your webserver logs, you should be able to find em based on the content length of the response?
a
One quick-and-dirty solution that isn't "manually add logging near your tags" is just to make a new tag entirely and then search-and-destroy all your
<cfabort
instance to
<cf_abortx
that does the logging you want.
I mean, doing it any of these other ways is probably better, but for completeness' sake I figured I'd mention it.