Module: Bulldogger::Record::SqliteConverter

Defined in:
lib/bulldogger/record/sqlite_converter.rb

Overview

Converts an existing trace-NNN.jsonl into a SQLite database, one row per event line.

sqlite3 is required here, and only inside #convert (soft require) -- never at the top of this file. The design principle is "CLI and any servers are thin adapters over the files": a live SQLite writer running alongside the JSONL writer would make SQLite a second product instead of an adapter, and requiring the gem unconditionally would add a runtime dependency the core does not carry. When sqlite3 is not installed, this returns nil rather than raising, so a caller that never asked for SQL access is never broken by its absence.

Class Method Summary collapse

Class Method Details

.convert(jsonl_path, db_path) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/bulldogger/record/sqlite_converter.rb', line 21

def convert(jsonl_path, db_path)
  require "sqlite3"
rescue LoadError => e
  # Unconditional, not gated by BULLDOGGER_DEBUG: the contract
  # requires an explicit signal, not a silent nil, when sqlite3
  # is unavailable ("使えないことを明示的に伝えて nil を返す").
  # The debug gate elsewhere in this codebase exists for the
  # :call/:return/:raise hooks, which fire on every traced
  # event and must stay silent by default; to_sqlite is a
  # single explicit call a caller made on purpose, never a hot
  # path, so warning every time costs nothing worth hiding.
  warn("bulldogger: sqlite3 not available (#{e.class}: #{e.message}); to_sqlite returning nil")
  nil
else
  write_database(jsonl_path, db_path)
  db_path
end