Class: Logrithm::Log
Constant Summary collapse
- JOINER =
"#{$/} #{option(:log, :joiners, :objects) || '⮩ '}".freeze
- USE_GLOBAL_SELF =
option(:log, :global_self) || false
- INSTANCE =
Log.new
Class Method Summary collapse
Instance Method Summary collapse
- #flush ⇒ Object
-
#initialize(log = nil, **params) ⇒ Log
constructor
A new instance of Log.
- #level=(level = nil) ⇒ Object
- #logger ⇒ Object
Constructor Details
#initialize(log = nil, **params) ⇒ Log
Returns a new instance of Log.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/logrithm/log.rb', line 12 def initialize(log = nil, **params) [ File.join(__dir__, '..', '..', 'config', 'logrithm.yml'), (File.join((Rails.root || '.'), 'config', 'logrithm.yml') if Logrithm.rails?) ].compact.each do |cfg| kungfuig(cfg) if File.exist?(cfg) end kungfuig(params) ensure_logger(log) if log @leader = {} @colors = {} end |
Class Method Details
.app_root ⇒ Object
70 71 72 |
# File 'lib/logrithm/log.rb', line 70 def app_root File.realpath(INSTANCE.option(:log, :root) || Logrithm.rails? && Rails.root || File.join(__dir__, '..', '..')) end |
.option(*name) ⇒ Object
66 67 68 |
# File 'lib/logrithm/log.rb', line 66 def option(*name) INSTANCE.option(*name) end |
Instance Method Details
#flush ⇒ Object
30 31 32 |
# File 'lib/logrithm/log.rb', line 30 def flush logdev.flush end |
#level=(level = nil) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/logrithm/log.rb', line 34 def level=(level = nil) logger.level = level || case Logrithm.env when :dev, :development, :test then Logger::DEBUG else Logger::INFO end end |
#logger ⇒ Object
26 27 28 |
# File 'lib/logrithm/log.rb', line 26 def logger ensure_logger end |