Module: ActiveCypher::Logging
- Included in:
- Base, Model::ConnectionOwner, Relationship
- Defined in:
- lib/active_cypher/logging.rb
Class Attribute Summary collapse
-
.backend ⇒ Object
The one true logger object.
Class Method Summary collapse
-
.logger ⇒ Object
Public accessor used by the mix‑in.
Instance Method Summary collapse
- #log_bench(label) ⇒ Object
- #log_debug(msg) ⇒ Object
- #log_error(msg) ⇒ Object
- #log_info(msg) ⇒ Object
- #log_warn(msg) ⇒ Object
-
#logger ⇒ Object
—————————————————————— Instance helpers ——————————————————————.
Class Attribute Details
.backend ⇒ Object
The one true logger object
10 11 12 |
# File 'lib/active_cypher/logging.rb', line 10 def backend @backend end |
Class Method Details
.logger ⇒ Object
Public accessor used by the mix‑in
13 14 15 16 17 18 19 20 |
# File 'lib/active_cypher/logging.rb', line 13 def logger self.backend ||= begin base = Logger.new($stdout) base.level = ENV.fetch('AC_LOG_LEVEL', 'info').upcase .then { |lvl| Logger.const_get(lvl) } ActiveSupport::TaggedLogging.new(base).tap { |l| l.tagged! 'ActiveCypher' } end end |
Instance Method Details
#log_bench(label) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/active_cypher/logging.rb', line 32 def log_bench(label) start = Process.clock_gettime(Process::CLOCK_MONOTONIC) yield ensure ms = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - start) * 1_000).round(2) logger.debug { "#{label} (#{ms} ms)" } end |
#log_debug(msg) ⇒ Object
27 |
# File 'lib/active_cypher/logging.rb', line 27 def log_debug(msg) = logger.debug { msg } |
#log_error(msg) ⇒ Object
30 |
# File 'lib/active_cypher/logging.rb', line 30 def log_error(msg) = logger.error { msg } |
#log_info(msg) ⇒ Object
28 |
# File 'lib/active_cypher/logging.rb', line 28 def log_info(msg) = logger.info { msg } |
#log_warn(msg) ⇒ Object
29 |
# File 'lib/active_cypher/logging.rb', line 29 def log_warn(msg) = logger.warn { msg } |