Skip to content

Add log operation for debugging and pass-through functionality - #9

Merged
jmalovera10 merged 1 commit into
mainfrom
feature/log-operation
Sep 14, 2026
Merged

jmalovera10 merged 1 commit into
mainfrom
feature/log-operation

Conversation

@jmalovera10

@jmalovera10 jmalovera10 commented Sep 14, 2026 •

Copy link
Copy Markdown
Owner

Description

Adds a log operation to OperationEvaluator: {"log": message} evaluates message (any
nested expression), logs it via Logger.debug/1, and returns the evaluated value unchanged
— a transparent pass-through, not a fixed sentinel. Because it returns its argument's value
rather than replacing it, log can be wrapped around any part of a rule's conditions or
actions without changing what the rule decides, purely for debugging intermediate values —
e.g. {"gt": [{"log": {"obj": "order.total"}}, 100]} logs order.total while still comparing
it normally, and a whole rule's conditions can be wrapped in log to trace its final decision.

Changes

  • lib/operation_evaluator.ex: require Logger; new log clause — evaluates its argument,
    logs it via a loggable/1 helper (binaries logged as-is, everything else via inspect/1),
    and returns the evaluated value unchanged.
  • test/operation_evaluator_test.exs: new describe "log operation" block (8 cases) covering
    plain-string, nested obj, and nested computed messages; non-binary stringification;
    propagated evaluation errors from a bad nested reference; composition inside a gt
    comparison; composition as a rule's entire top-level conditions (via
    StatefulRuleEngine); and wrapping set as an action.
  • README.md: new "Logging Operations" table, including the pass-through note and a caution
    against logging sensitive fact values.
  • CHANGELOG.md: [Unreleased] → Added entry.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Test updates

How Has This Been Tested?

  • mix test — 164 tests, 0 failures, including the full pre-existing suite unmodified plus 8
    new log operation cases (plain/nested/composed messages, non-binary stringification,
    propagated errors, composition inside a comparison, composition as top-level conditions,
    wrapping set).

  • mix credo — no issues.

  • mix dialyzer — 0 errors.

  • mix sobelow — no new findings (see Additional Notes for one pre-existing, unrelated
    line-number shift).

  • Unit tests pass

  • Integration tests pass

  • Manual testing completed

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@jmalovera10 jmalovera10 changed the title feat: Add log operation for debugging and pass-through functionality Add log operation for debugging and pass-through functionality Sep 14, 2026
@jmalovera10
jmalovera10 merged commit ebeec37 into main Sep 14, 2026
16 checks passed
@jmalovera10
jmalovera10 deleted the feature/log-operation branch September 14, 2026 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant