Class: Loba::Internal::Settings Private
- Inherits:
-
Object
- Object
- Loba::Internal::Settings
- Defined in:
- lib/loba/internal/settings.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Internal class for tracking output and logging settings based on supplied options
Instance Attribute Summary collapse
-
#log ⇒ boolean
(also: #log?)
readonly
private
Whether logging is performed.
-
#logdev ⇒ nil, ...
readonly
private
Any custom (overridden) logging device being written to;
nil
if none specified. -
#logger ⇒ Logger
readonly
private
::Logger
used for logging; may benil
if not logging. -
#out ⇒ boolean
(also: #out?)
readonly
private
false
if console output is suppressed; otherwise,true
. -
#production ⇒ boolean
(also: #production?)
readonly
private
true
if Loba is enabled even within a Rails production environment; otherwise,false
.
Instance Method Summary collapse
-
#disabled? ⇒ Boolean
private
true
if Loba is skipped (because of a production environment); otherwise,false
. -
#enabled? ⇒ Boolean
private
true
if Loba is used; otherwise,false
. -
#initialize(log: nil, logger: nil, logdev: nil, out: true, production: false) ⇒ Settings
constructor
private
A new instance of Settings.
Constructor Details
#initialize(log: nil, logger: nil, logdev: nil, out: true, production: false) ⇒ Settings
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
To avoid doubled output, if a non-Rails logger is to be logged to and logdev
is set to $stdout, then output will be suppressed (i.e., settings.out
is false
). Doubled output can still occur; in that case, explicitly use out: false.
Returns a new instance of Settings.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/loba/internal/settings.rb', line 43 def initialize(log: nil, logger: nil, logdev: nil, out: true, production: false) @raw_log_argument = log @log = validated_log(log) @out = false @production = validated_production(production) return unless enabled? @logger = validated_logger(logger) @logdev = validated_logdev(logdev) @out = validated_out(out) configure_logging end |
Instance Attribute Details
#log ⇒ boolean (readonly) Also known as: log?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether logging is performed.
6 7 8 |
# File 'lib/loba/internal/settings.rb', line 6 def log @log end |
#logdev ⇒ nil, ... (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns any custom (overridden) logging device being written to; nil
if none specified.
14 15 16 |
# File 'lib/loba/internal/settings.rb', line 14 def logdev @logdev end |
#logger ⇒ Logger (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns ::Logger
used for logging; may be nil
if not logging.
10 11 12 |
# File 'lib/loba/internal/settings.rb', line 10 def logger @logger end |
#out ⇒ boolean (readonly) Also known as: out?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns false
if console output is suppressed; otherwise, true
.
17 18 19 |
# File 'lib/loba/internal/settings.rb', line 17 def out @out end |
#production ⇒ boolean (readonly) Also known as: production?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns true
if Loba is enabled even within a Rails production environment; otherwise, false
.
22 23 24 |
# File 'lib/loba/internal/settings.rb', line 22 def production @production end |
Instance Method Details
#disabled? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns true
if Loba is skipped (because of a production environment); otherwise, false
.
65 66 67 |
# File 'lib/loba/internal/settings.rb', line 65 def disabled? !enabled? end |
#enabled? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns true
if Loba is used; otherwise, false
.
59 60 61 |
# File 'lib/loba/internal/settings.rb', line 59 def enabled? production? || !Internal::Platform::WithinRails.production? end |