Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[merb-core] Extracted Merb.verbose_logging? method

Dries up repeated use of rather verbose environment
check. Also provides an easily accessible guard that
can be used to check if really verbose debug messages
should be emitted.

[#1044 state:resolved]
  • Loading branch information...
commit 823e14f2d34770b2c60f6b0cc16f6ff5533e0785 1 parent 923406a
@snusnu snusnu authored
View
8 merb-core/lib/merb-core.rb
@@ -534,6 +534,14 @@ def bundled?
$BUNDLE || ENV.key?("BUNDLE")
end
+ # ==== Returns
+ # Boolean:: True if Merb is running in debug or verbose mode
+ #
+ # :api: public
+ def verbose_logging?
+ (ENV['DEBUG'] || $DEBUG || Merb::Config[:verbose]) && Merb.logger
+ end
+
# Load configuration and assign the logger.
#
# ==== Parameters
View
10 merb-core/lib/merb-core/bootloader.rb
@@ -93,13 +93,9 @@ def run
until subclasses.empty?
time = Time.now.to_i
bootloader = subclasses.shift
- if (ENV['DEBUG'] || $DEBUG || Merb::Config[:verbose]) && Merb.logger
- Merb.logger.debug!("Loading: #{bootloader}")
- end
+ Merb.logger.debug!("Loading: #{bootloader}") if Merb.verbose_logging?
Object.full_const_get(bootloader).run
- if (ENV['DEBUG'] || $DEBUG || Merb::Config[:verbose]) && Merb.logger
- Merb.logger.debug!("It took: #{Time.now.to_i - time}")
- end
+ Merb.logger.debug!("It took: #{Time.now.to_i - time}") if Merb.verbose_logging?
self.finished << bootloader
end
self.subclasses = subklasses
@@ -399,7 +395,7 @@ def self.run
#
# :api: private
def self.load_bundler_dependencies
- if (ENV['DEBUG'] || $DEBUG || Merb::Config[:verbose]) && Merb.logger
+ if Merb.verbose_logging?
if Merb::Config[:gemfile]
Merb.logger.debug!("Loading Gemfile from #{Merb::Config[:gemfile]}")
else
Please sign in to comment.
Something went wrong with that request. Please try again.