Module: Assistant::LogList

Included in:
Service
Defined in:
lib/assistant/log_list.rb

Overview

Mixin that gives Assistant::Service its log timeline. Owns the @logs array and exposes the public helpers (#add_log, #merge_logs, the log_item_* shorthands, #infos / #warnings / #errors) used by service code to record observations and by callers to read the result.

Instance Method Summary collapse

Instance Method Details

#add_log(level:, source:, detail:, message:, trace: nil) ⇒ Array<Assistant::LogItem>

Append a single Assistant::LogItem to the timeline.

Parameters:

  • level (Symbol)

    :info, :warning, or :error

  • source (Symbol)

    subsystem identifier

  • detail (Symbol)

    sub-identifier (often an attribute name)

  • message (String)

    human-readable message

  • trace (Array<String>, nil) (defaults to: nil)

    optional backtrace

Returns:

Raises:



18
19
20
# File 'lib/assistant/log_list.rb', line 18

def add_log(level:, source:, detail:, message:, trace: nil)
  @logs << Assistant::LogItem.new(level:, source:, detail:, message:, trace:)
end

#log_item_error_initialize(attr_name:, message:) ⇒ Array<Assistant::LogItem>

Convenience used by InputBuilder-generated validators to record an initialization-time error for a specific input attribute.

Parameters:

  • attr_name (Symbol)

    the offending input name (recorded as detail)

  • message (String)

    human-readable explanation

Returns:



37
38
39
# File 'lib/assistant/log_list.rb', line 37

def log_item_error_initialize(attr_name:, message:)
  @logs << Assistant::LogItem.new(detail: attr_name, level: :error, message:, source: :initialize)
end

#merge_logs(logs:) ⇒ Array<Assistant::LogItem>

Concatenate an existing log timeline onto this service's @logs, preserving insertion order. Used by Service#call_service (M-S2).

Parameters:

Returns:



27
28
29
# File 'lib/assistant/log_list.rb', line 27

def merge_logs(logs:)
  @logs.concat(logs)
end