lib/glue/configuration.rb in glue-0.40.0 vs lib/glue/configuration.rb in glue-0.41.0
- old
+ new
@@ -115,16 +115,48 @@
#
# [:live]
# use the parameters for the live (production)
# server. Optimized for speed.
#
- # Tries to set the default value from the CONFIGURATION_MODE
+ # Tries to set the default value from the NITRO_MODE
# environment variable.
attr_accessor :mode
def mode
- @mode || ENV.fetch('CONFIGURATION_MODE', :debug).to_sym
+ mode = nil
+ if mode = ENV['CONFIGURATION_MODE']
+ $stderr.puts "CONFIGURATION_MODE is deprecated, use NITRO_MODE"
+ end
+ @mode || mode || ENV.fetch('NITRO_MODE', :debug).to_sym
+ end
+
+ # The log output destination.
+ #
+ # ['STDOUT' 'STDERR']
+ # Sets the log to stdout or stderr.
+ #
+ # [str]
+ # Any other string is regarded as path
+
+ attr_accessor :log
+
+ def log
+ return @log if @log
+
+ log = ENV.fetch('NITRO_LOG', Logger.new('log/app.log'))
+
+ if log.kind_of?(String)
+ if log =~ /(STD(?:OUT|ERR))/i
+ log = Object.const_get($1.upcase)
+ elsif File.directory?(File.dirname(log))
+ log = Logger.new(log)
+ else
+ log = 'log/app.log'
+ end
+ end
+
+ @log = log
end
alias kernel_load load
# Attempt to load external configuration in Ruby or