feat(adapters): implement adapters/log -- daw_log/v1 sink and router #118

Closed
opened 2026-06-03 09:26:18 +02:00 by michael · 1 comment
Owner

Goal

Implement adapters/log in fragjan -- the single sink for daw_log/v1 messages.
Follows the interface adapter pattern (adapters/storage).
Concept defined in DAW/fragjan#97.

Architecture

daw.common.log -> daw_log/v1 -> adapters/log -> daw.log.file   (module)
                                             -> daw.log.syslog (module)
                                             -> adapters/ui    (direct)

Required operations

M._contracts = {
  check        = "bool_or_err",
  required_ops = "list",
  open         = "bool_or_err",
  write        = "bool_or_err",
  close        = "bool_or_err",
}

-- open(cfg)    -> true|nil, err   -- initialize all configured targets
-- write(entry) -> true|nil, err   -- route daw_log/v1 to matching targets
-- close()      -> nil             -- release all target resources

Level filtering

Each target defines its minimum level independently via config.
adapters/log filters per target before dispatching.

Level order: DEBUG < INFO < WARN < ERROR < FAULT

Config (fragjan.conf)

[logging.file]
level = info
path  = var/log/fragjan.log

[logging.debug]
level = debug
path  = var/log/fragjan.debug.log

[logging.syslog]
level = warn

[logging.ui]
level = error

All targets optional. Absent section = target inactive. No error.
[logging.debug] is a second daw.log.file instance -- not a special case.
[logging.ui] routes to adapters/ui directly, no module.

Startup behavior

adapters/log is initialized in main.lua before ctx is fully built.
On open() failure (missing module, bad config):

  • main.lua writes pre-error directly to stderr
  • follows same pattern as other early startup failures
  • fragjan exits, no silent fallback

If no [logging.*] section is configured: adapters/log is inactive.
No error. Intentional zero-logging is valid.

Module interface (daw.log.*)

open(config)   -> true|nil, err
write(entry)   -> true|nil, err   -- entry is daw_log/v1 table
close()        -> nil

Acceptance criteria

  • _contracts and required_ops() defined
  • open() loads and initializes all configured targets
  • write() filters by level per target, dispatches daw_log/v1
  • close() releases all target resources
  • [logging.ui] routes to adapters/ui directly, no module
  • open() failure handled as pre-error in main.lua
  • test/adapters/test_log.lua covers interface contract

Dependencies

## Goal Implement adapters/log in fragjan -- the single sink for daw_log/v1 messages. Follows the interface adapter pattern (adapters/storage). Concept defined in DAW/fragjan#97. ## Architecture ``` daw.common.log -> daw_log/v1 -> adapters/log -> daw.log.file (module) -> daw.log.syslog (module) -> adapters/ui (direct) ``` ## Required operations ```lua M._contracts = { check = "bool_or_err", required_ops = "list", open = "bool_or_err", write = "bool_or_err", close = "bool_or_err", } -- open(cfg) -> true|nil, err -- initialize all configured targets -- write(entry) -> true|nil, err -- route daw_log/v1 to matching targets -- close() -> nil -- release all target resources ``` ## Level filtering Each target defines its minimum level independently via config. adapters/log filters per target before dispatching. Level order: DEBUG < INFO < WARN < ERROR < FAULT ## Config (fragjan.conf) ```ini [logging.file] level = info path = var/log/fragjan.log [logging.debug] level = debug path = var/log/fragjan.debug.log [logging.syslog] level = warn [logging.ui] level = error ``` All targets optional. Absent section = target inactive. No error. [logging.debug] is a second daw.log.file instance -- not a special case. [logging.ui] routes to adapters/ui directly, no module. ## Startup behavior adapters/log is initialized in main.lua before ctx is fully built. On open() failure (missing module, bad config): - main.lua writes pre-error directly to stderr - follows same pattern as other early startup failures - fragjan exits, no silent fallback If no [logging.*] section is configured: adapters/log is inactive. No error. Intentional zero-logging is valid. ## Module interface (daw.log.*) ``` open(config) -> true|nil, err write(entry) -> true|nil, err -- entry is daw_log/v1 table close() -> nil ``` ## Acceptance criteria - [ ] _contracts and required_ops() defined - [ ] open() loads and initializes all configured targets - [ ] write() filters by level per target, dispatches daw_log/v1 - [ ] close() releases all target resources - [ ] [logging.ui] routes to adapters/ui directly, no module - [ ] open() failure handled as pre-error in main.lua - [ ] test/adapters/test_log.lua covers interface contract ## Dependencies - DAW/fragjan#97 -- concept and contract definition - DAW/fragjan#95 -- daw.common.log (producer, depends on this) - DAW/fragjan#117 -- daw.log.file (first backend module) - DAW/fragjan#90 -- adapters/ui render() (done in v0.3.0)
Author
Owner

Implemented and deployed. adapters/log routes daw_log/v1 via mod_modules.resolve() to configured backends. Level filtering working. Tested with daw.log.file v0.1.3.

Implemented and deployed. adapters/log routes daw_log/v1 via mod_modules.resolve() to configured backends. Level filtering working. Tested with daw.log.file v0.1.3.
michael added this to the Basic Version milestone 2026-06-04 11:29:48 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DAW/fragjan#118
No description provided.