Skip to content

Commit

Permalink
Add ENV variable to debug zeitwerk
Browse files Browse the repository at this point in the history
It's far easier to debug in dev/test/containers using an ENV variable
so we'll make it so zeitwerk stdout logging and eager loading of all engines
is only done with this flag enabled.
  • Loading branch information
jrafanie committed Jun 5, 2023
1 parent 8014f97 commit 7f97ba0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,11 @@ class Application < Rails::Application
end

initializer :eager_load_all_the_things, :after => :load_config_initializers do
config.eager_load_paths += config.autoload_paths
Vmdb::Plugins.each do |plugin|
plugin.config.eager_load_paths += plugin.config.autoload_paths
if ENV['DEBUG_MANAGEIQ_ZEITWERK'].present?
config.eager_load_paths += config.autoload_paths
Vmdb::Plugins.each do |plugin|
plugin.config.eager_load_paths += plugin.config.autoload_paths
end
end
end

Expand Down
6 changes: 4 additions & 2 deletions config/initializers/zeitwerk.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
if Rails.application.config.autoloader == :zeitwerk && Rails.autoloaders.main
Zeitwerk::Loader.default_logger = method(:puts)
Rails.autoloaders.main.logger = Logger.new(STDOUT)
if ENV['DEBUG_MANAGEIQ_ZEITWERK'].present?
Zeitwerk::Loader.default_logger = method(:puts)
Rails.autoloaders.main.logger = Logger.new(STDOUT)
end

# These specific directories are for code organization, not namespacing:
Rails.autoloaders.main.collapse(Rails.root.join("lib/manageiq/reporting/charting"))
Expand Down

0 comments on commit 7f97ba0

Please sign in to comment.