Module: Axn::Internal::CallLogger
Overview
Logs action execution - handles building and emitting structured log messages for action calls with context formatting and truncation.
Constant Summary collapse
- MAX_CONTEXT_LENGTH =
150- TRUNCATION_SUFFIX =
"…<truncated>…"
Instance Method Summary collapse
-
#log_at_level(action_class, level:, message_parts:, error_context:, join_string: " ", before: nil, after: nil, prefix: nil, context_direction: nil, context_instance: nil, context_data: nil) ⇒ Object
Logs a message at the specified level with error handling.
Instance Method Details
#log_at_level(action_class, level:, message_parts:, error_context:, join_string: " ", before: nil, after: nil, prefix: nil, context_direction: nil, context_instance: nil, context_data: nil) ⇒ Object
Logs a message at the specified level with error handling
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/axn/internal/call_logger.rb', line 25 def log_at_level( action_class, level:, message_parts:, error_context:, join_string: " ", before: nil, after: nil, prefix: nil, context_direction: nil, context_instance: nil, context_data: nil ) return unless level # Prepare and format context if needed context_str = if context_instance && context_direction # Instance-level: use private inputs_for_logging / outputs_for_logging data = case context_direction when :inbound then context_instance.send(:inputs_for_logging) when :outbound then context_instance.send(:outputs_for_logging) end format_context(data) elsif context_data && context_direction # Class-level: use internal _context_slice data = action_class._context_slice(data: context_data, direction: context_direction) format_context(data) end # Add context to message parts if present = context_str ? + [context_str] : = .compact.join(join_string) action_class.public_send(level, , before:, after:, prefix:) rescue StandardError => e Axn::Internal::PipingError.swallow(error_context, action: action_class, exception: e) end |