# Helper code for logging loaded extensions

**URL:** <https://www.ruby-forum.com/t/helper-code-for-logging-loaded-extensions/126643>\
**Category:** Radiant CMS\
**Created:** [January 20, 2008, 10:35pm UTC](https://www.ruby-forum.com/t/helper-code-for-logging-loaded-extensions/126643 "2008-01-20T22:35:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [January 20, 2008, 10:35pm UTC](https://www.ruby-forum.com/t/helper-code-for-logging-loaded-extensions/126643/1 "2008-01-20T22:35:17Z")

</div>

I am working on a custom project and developing my own extensions and  
plugins. Additionally, I am integrating third party extensions into my  
Radiant site. Periodically, these custom or third party extensions have  
issues that prevent the application from properly loading, particularly  
when uploading a site to a host. The error message you get in console  
sometimes is cryptic and so you’re not really even thinking that an  
extension may be to blame. At least this was true with me…

I found it extremely helpful for debugging to put a line something like  
this at the top of my extension files:

puts “Loading MyExtension…”

Since then I’ve simply moved this to a separate file:

load\_loaded\_dependencies.rb:

module Dependencies  
alias old\_log\_call log\_call  
def log\_call(_args)  
begin  
relative\_filename =  
(args[0].to\_s.match(’/vendor/._’)[0]).to\_s.gsub(’/vendor/’,’’) rescue  
nil  
puts “Loading dependency: #{relative\_filename}” if  
relative\_filename && relative\_filename != @@last\_relative\_filename  
@@last\_relative\_filename = relative\_filename  
rescue  
ensure  
old\_log\_call args  
end  
end  
end

Then, I simply require this file at the top of my environment.rb file.

Hope this is useful to someone else.

Mario
