Skip to main content
Known Participant
May 29, 2009
Question

Logging calls to cfcs

  • May 29, 2009
  • 2 replies
  • 1235 views

Howdy gang!

I have inherited an application with a fairly large number of cfcs. The codebase goes back quite a few years. Though the code is in mostly decent shape, as with most long lived apps, there are files no longer in use, etc.

I am hoping to figure out a way to monitor cfc usage. Ideally, I would be getting something like:

* cfc name

* method

* file called from

* maybe args passed 

I would stuff this info in to a table, so I can basically select all cfcs that have not seen any use in a given time period.

Coming up completely blank on this one. Any ideas? Thanks!

    This topic has been closed for replies.

    2 replies

    BKBK
    Community Expert
    Community Expert
    May 30, 2009

    Typically something for Coldspring AOP.

    Participating Frequently
    May 30, 2009

    One note: In my response I assumed that OP wants to touch the existing

    code as little as possible.

    My limited understanding of ColdSpring makes me to believe that you'll

    need to declare proxy objects for all your CFC's and then use the bean

    factory to get the actual instances (and this means modification to

    all CFC's, even those that are not used).

    Mack

    Known Participant
    May 30, 2009

    Some interesting ideas so far. Mack seems to have the down-and-dirty but global approach in mind, which is what this is almost certainly going to require. Aspect Oriented concepts have always intrigued me, to the point of implementing them to an extent whenever possible for application-wide concerns such as authentication and authorization, logging etc. However, the existing codebase, about 1.5 million lines worth, was originally written in a Fusebox-ish style, so pouring it in to Coldspring or any framework would be a project of Herculean proportion!

    When CF's debug is turned on, it displays a nice little list of what called what CFC. That makes it seem like the code that generates that output is hooking in to something that has the info I am hoping to find. I have gone in to the guts of CF a bit looking for it, but am not even close. If I could get my grimy mitts on that, it would then be a matter of writing a function that grabs the data and stores it, then... pasting a call to that function in to every... single.. existing function. Ugly indeed, but it could be made to work. I think we have on the order of 500 or so functions, so that would be a fun day. I heard it said once that copy/paste is a code design defect. Love it!

    Still scratching my head a bit here. Thanks for the ideas so far, and please keep them coming! This is a common issue faced when inheriting legacy code, so a workable solution could be a big deal for lots of programmers.

    Participating Frequently
    May 30, 2009

    A couple of ideas :

    - reset the access time of all CFC's to a known date (2007-01-01 for

    example). After a while see what CFC's changed their access time (this

    requires a file system that supports access time though);

    - in component.cfc (base component from which all components derive)

    place code in the constructor area to log the object creation.

    None of the ideas bring you to 100% coverage and both have

    disadvantages (for the first you need to avoid a lot of operation on

    the CFC's that would impact their access time, the second will not

    work on a shared host, etc).

    Mack