Skip to content

Commit

Permalink
More logging and notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
paneq committed Oct 9, 2011
1 parent a1d8d62 commit 463f905
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -13,3 +13,4 @@ test/dummy*/vendor/bundle/

test/dummy310rc6/app/controllers/root_controller.rb
test/dummy3010/app/controllers/root_controller.rb
test/dummy310rc6/log/dependencies/
24 changes: 23 additions & 1 deletion test/dummy3010/config/environments/development.rb
Expand Up @@ -26,4 +26,26 @@
config.action_dispatch.best_standards_support = :builtin

config.middleware.insert_after(ActionDispatch::Static, DefinedMiddleware)
end
end

# http://railscasts.com/episodes/249-notifications-in-rails-3
ActiveSupport::Notifications.subscribe("active_support.dependencies.clear") do |*args|
msg = "Code reloaded!"
# Libnotify.show(:body => msg, :summary => Rails.application.class.name, :timeout => 2.5, :append => true) # https://github.com/splattael/libnotify
puts msg
Rails.logger.info(" --- #{msg} --- ")
end

ActiveSupport::Notifications.subscribe("active_reload.set_clear_dependencies_hook_replaced") do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
msg = event.name
# Libnotify.show(:body => msg, :summary => Rails.application.class.name, :timeout => 2.5, :append => true) # https://github.com/splattael/libnotify
puts msg
Rails.logger.warn(" --- #{msg} --- ")
end

# Log how dependencies (constants) are resolved automatically and when they are unloaded.
dependencies_logger_dir = File.join(Rails.root, 'log', 'dependencies')
FileUtils.mkpath(dependencies_logger_dir)
ActiveSupport::Dependencies.log_activity = true
ActiveSupport::Dependencies.logger = Logger.new(File.join(dependencies_logger_dir, Rails.env + '.log'))
10 changes: 9 additions & 1 deletion test/dummy310rc6/config/environments/development.rb
Expand Up @@ -34,12 +34,20 @@
ActiveSupport::Notifications.subscribe("active_support.dependencies.clear") do |*args|
msg = "Code reloaded!"
# Libnotify.show(:body => msg, :summary => Rails.application.class.name, :timeout => 2.5, :append => true) # https://github.com/splattael/libnotify
puts msg
Rails.logger.info(" --- #{msg} --- ")
end

ActiveSupport::Notifications.subscribe("active_reload.set_clear_dependencies_hook_replaced") do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
msg = event.name
# Libnotify.show(:body => msg, :summary => Rails.application.class.name, :timeout => 2.5, :append => true) # https://github.com/splattael/libnotify
puts msg
Rails.logger.warn(" --- #{msg} --- ")
end
end

# Log how dependencies (constants) are resolved automatically and when they are unloaded.
dependencies_logger_dir = File.join(Rails.root, 'log', 'dependencies')
FileUtils.mkpath(dependencies_logger_dir)
ActiveSupport::Dependencies.log_activity = true
ActiveSupport::Dependencies.logger = Logger.new(File.join(dependencies_logger_dir, Rails.env + '.log'))

0 comments on commit 463f905

Please sign in to comment.