Add log operation for debugging and pass-through functionality - #9
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a
logoperation toOperationEvaluator:{"log": message}evaluatesmessage(anynested 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,
logcan be wrapped around any part of a rule'sconditionsoractionswithout changing what the rule decides, purely for debugging intermediate values —e.g.
{"gt": [{"log": {"obj": "order.total"}}, 100]}logsorder.totalwhile still comparingit normally, and a whole rule's
conditionscan be wrapped inlogto trace its final decision.Changes
lib/operation_evaluator.ex:require Logger; newlogclause — evaluates its argument,logs it via a
loggable/1helper (binaries logged as-is, everything else viainspect/1),and returns the evaluated value unchanged.
test/operation_evaluator_test.exs: newdescribe "log operation"block (8 cases) coveringplain-string, nested
obj, and nested computed messages; non-binary stringification;propagated evaluation errors from a bad nested reference; composition inside a
gtcomparison; composition as a rule's entire top-level
conditions(viaStatefulRuleEngine); and wrappingsetas an action.README.md: new "Logging Operations" table, including the pass-through note and a cautionagainst logging sensitive fact values.
CHANGELOG.md:[Unreleased]→ Added entry.Type of Change
How Has This Been Tested?
mix test— 164 tests, 0 failures, including the full pre-existing suite unmodified plus 8new
log operationcases (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, unrelatedline-number shift).
Unit tests pass
Integration tests pass
Manual testing completed
Checklist