Skip to content

Logging

ORM::ActiveRecord uses Log::Async under the hood. Loading the library configures the INFO-level handler to write to $*OUT (stdout). That's the only log destination set up by default — loading the library does not touch the filesystem.

File logging

Set ORM_LOG_FILE in the process environment to an absolute or relative path, and ERROR-level messages will be appended to that file:

1
export ORM_LOG_FILE=log/error.log
1
2
use ORM::ActiveRecord::Model;   # adapters log via Support::Log
# ERROR-level entries now also write to ./log/error.log

Notes:

  • The path is resolved against the current working directory at the time the library is loaded. If the directory doesn't exist, opening the file will fail — create it first (mkdir log) or use an absolute path.
  • The variable is read once, when ORM::ActiveRecord::Support::Log is first loaded. Setting it after that point has no effect on the current process.
  • Unset or empty ORM_LOG_FILE ⇒ no file handler is attached. This keeps the library safe to load under tooling that runs from arbitrary working directories (LSP precompilation, CI matrices, cron jobs).
  • The bin/ar migration CLI defaults ORM_LOG_FILE to log/error.log — but only when a log/ directory exists in the current working directory. So running ar from the project root keeps the old file-logging behavior, while precompilation under tooling that runs from elsewhere (LSP, CI checkout from a parent dir, etc.) skips it cleanly. Export a different value before invoking ar to override.

Disabling SQL logging

Adapters emit each query at INFO level. To silence them, set:

1
export DISABLE-SQL-LOG=1

This is typically what you want under test suites — t/ already sets it where appropriate.