Module: Abqari::Log

Defined in:
lib/abqari/log.rb

Overview

Tiny leveled logger. No stdlib Logger ceremony — one module, four severity methods, level filtered at call time. Configured via the ABQARI_LOG env var (debug / info / warn / error). Default: info.

Why not Logger? Logger optimises for long-running processes that need rotation, formatters, custom output streams. Abqari is a build tool — output is short, lives in CI logs, and the operator wants:

- info  → user-facing progress (`Built 108 pages…`)
- debug → development triage  (`ABQARI_LOG=debug bin/build`)
- warn  → recoverable issue   (`Folio fetch failed — using cache`)
- error → fatal               (`render failed: …`)

Stderr for everything except info — info goes to stdout so it can be redirected separately. Matches the established convention from most Unix build tools.

No file output, no rotation, no formatters. Yagni.

Constant Summary collapse

LEVELS =
{ debug: 0, info: 1, warn: 2, error: 3 }.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.levelObject

Returns the value of attribute level.



29
30
31
# File 'lib/abqari/log.rb', line 29

def level
  @level
end

Class Method Details

.debug(msg) ⇒ Object



35
# File 'lib/abqari/log.rb', line 35

def debug(msg) = emit(:debug, msg, $stderr)

.error(msg) ⇒ Object



38
# File 'lib/abqari/log.rb', line 38

def error(msg) = emit(:error, msg, $stderr)

.info(msg) ⇒ Object



36
# File 'lib/abqari/log.rb', line 36

def info(msg)  = emit(:info, msg, $stdout)

.level_nameObject



31
32
33
# File 'lib/abqari/log.rb', line 31

def level_name
  LEVELS.key(@level) || :info
end

.warn(msg) ⇒ Object



37
# File 'lib/abqari/log.rb', line 37

def warn(msg)  = emit(:warn, msg, $stderr)