class Loba::Internal::Platform
Internal
class for managing logging across Rails and non-Rails applications
Public Class Methods
logger()
click to toggle source
Returns a logging mechanism appropriate for the application
# File lib/loba/internal/platform.rb, line 24 def logger if rails? && Rails.logger.present? ->(arg) { Rails.logger.debug arg } else ->(arg) { puts arg } end end
logging_ok?(force_true = false)
click to toggle source
Returns true if logging is to be allowed
# File lib/loba/internal/platform.rb, line 12 def logging_ok?(force_true = false) return true if force_true return true unless rails? begin !Rails.env.production? rescue StandardError true # let it attempt to log anyway end end
rails?()
click to toggle source
Returns true if Rails appears to be available
# File lib/loba/internal/platform.rb, line 7 def rails? defined?(Rails) ? true : false end