How can I map templates called or included within a page?

I’m looking for a way to map source file usage in my project.

I found that turning on the Debugging server setting lists execution time for each template called or included in a page, which is a great start. I’d like to extend this functionality for each template to log the template that called the function (or included the template) in the order they were called.

Background: The project I’m working on is very large and unwieldy…it has been worked on by dozens of programmers going back over a decade, all of whom seemed to have their own idea about how to “organize” the code. There are a few components and custom tags, but mainly cfincludes.

example: Foo.cfm sets x to some value, then includes Bar.cfm, which sets variable y, then includes Baz.cfm, which sets variable x to something else, etc… until you get to file Qux.cfm, which does something with variables x and y. Looking at Qux.cfm, I have no idea where x was last assigned. On top of that, many features of the code have gone through updates or rewrites, so we have filenames like Bar_v8.cfm, Baz_v10.cfm, Baz_v10_new.cfm, Qux_wmv.cfm, /v10/Qux_mp4.cfm, Qux_audio_v11.cfm, etc… each of which was seemingly copypasted from another similar file with a few changes, but using the same variable names.

In short, it’s a little slice of Hell :wink:

Oh, and there are over 3200 cfm files in the repo, and I’ve got a feeling that a huge percentage of the files are unused in the current version of the code, which sucks when I make a change to usefulHelperFunction() and I need to check every file that uses it. If I could access the debug info from the code I could log each template in a db table whenever it is called and eventually I might be able to cull the repo of obsolete files.

Whoops, didn’t mean to ramble so long…I think I went into a fugue state there :crazy_face:
Anyways, I think I could get what I need if there’s a way to access the raw info used by Lucee’s debugging templates.


1 Like

I’ve always wanted a utility that tells me what templates in the code base have never been touched. Any project that gets long in the tooth starts to experience this issue.

Is there really still nothing out there?

You could get that information out of the FusionReactor line performance profiler. There’s probably an easier way to do it tapping into the request debugging though to track what gets included.

you could use pagePoolList(), it’s limited to 1000 items but only files which have been accessed will be there. there’s also this

1 Like