Class: Loba::Internal::Platform
- Inherits:
-
Object
- Object
- Loba::Internal::Platform
- Defined in:
- lib/loba.rb
Overview
Internal class for managing logging across Rails and non-Rails applications
Class Method Summary collapse
-
.logger ⇒ Object
Returns a logging mechanism appropriate for the application.
-
.logging_ok?(force_true = false) ⇒ Boolean
Returns true if logging is to be allowed.
-
.rails? ⇒ Boolean
Returns true if Rails appears to be available.
Class Method Details
.logger ⇒ Object
Returns a logging mechanism appropriate for the application
268 269 270 271 272 273 274 |
# File 'lib/loba.rb', line 268 def logger if (rails? && Rails.logger.present?) ->(arg){Rails.logger.debug arg} else ->(arg){puts arg} end end |
.logging_ok?(force_true = false) ⇒ Boolean
Returns true if logging is to be allowed
257 258 259 260 261 262 263 264 265 |
# File 'lib/loba.rb', line 257 def logging_ok?(force_true = false) return true if force_true return true unless rails? begin !Rails.env.production? rescue true # not Rails production if Rails isn't recognized end end |
.rails? ⇒ Boolean
Returns true if Rails appears to be available
252 253 254 |
# File 'lib/loba.rb', line 252 def rails? defined?(Rails) end |