Claus Ibsen created CAMEL-27657:
-----------------------------------
Summary: camel-log: showExchangePattern=false ignored,
multiline+maxChars<=0 broken, metadata gaps
Key: CAMEL-27657
URL: https://issues.apache.org/jira/browse/CAMEL-27657
Project: Camel
Issue Type: Bug
Components: camel-log
Reporter: Claus Ibsen
Fix For: 4.24.0
Found while improving the option descriptions of camel-log for CAMEL-23832
(commit
https://github.com/apache/camel/commit/cf85ff4549a0cb5bb88ecafc9f8a2d6fd8ae95bc).
These are separate problems of the component; the descriptions commit only
documents the current behavior.
h4. 1. showExchangePattern=false does not hide the exchange pattern
{{LogComponent.doInit()}} builds the shared default formatter with
{{setShowExchangePattern(true)}}. {{LogEndpoint.doInit()}} uses that shared
formatter when none of the formatting options is "changed", and its check only
looks at {{showExchangePattern == true}}. So
{{log:foo?showExchangePattern=false}} still logs {{ExchangePattern: InOnly}},
while {{log:foo?showHeaders=true}} hides the pattern although
{{showExchangePattern}} was not touched. The metadata says the default is
{{false}}.
Proposed change: make the endpoint default match the shared formatter (or track
whether the option was set), so the option and its default describe the output.
h4. 2. multiline=true with maxChars of 0 or less breaks the output
{{DefaultExchangeFormatter.format()}} (camel-support) enters the cut loop
whenever {{multiline}} is true and cuts each line with {{s.substring(0,
maxChars)}} when {{s.length() > maxChars}}. With {{maxChars=0}} every line
becomes {{...}}; with a negative value it throws
{{StringIndexOutOfBoundsException}}. Without multiline, 0 means no limit and a
negative value logs {{[Body is not logged]}}.
{code:java}
from("direct:a").to("log:foo?multiline=true&maxChars=0"); // logs only "..."
lines
from("direct:b").to("log:foo?multiline=true&maxChars=-1"); //
StringIndexOutOfBoundsException
{code}
Proposed change: only cut lines when {{maxChars > 0}}, as the single-line path
does.
h4. 3. The logger URI parameter is not a documented option
{{LogComponent.getLogger()}} reads a {{logger}} parameter (a reference to an
{{org.slf4j.Logger}}) and removes it before the endpoint options are set, so it
never appears in the component JSON, the doc page option table or the Endpoint
DSL. Only the prose of the doc page mentions {{?logger=#myLogger}}.
Proposed change: add it as an {{@UriParam}} on {{LogEndpoint}} (the
{{providedLogger}} field).
h4. 4. groupDelay has no defaultValue
{{ThroughputLogger}} uses {{groupDelay = 1000}} ms when the option is not set,
but the {{groupDelay}} option of {{LogEndpoint}} has no {{defaultValue}}.
Proposed change: add {{defaultValue = "1000"}} (or make the field a {{long}}
with that default).
h4. 5. Doc page and DefaultExchangeFormatter texts are out of date
The "URI format" section of {{log-component.adoc}} writes
{{log:loggingCategory}}, while the syntax and path option are {{loggerName}}.
{{DefaultExchangeFormatter}} (camel-support) keeps its own copy of the old
formatting option texts, including the typo "f the exchange has a caught
exception".
Proposed change: use {{loggerName}} in the doc page, and align the
{{DefaultExchangeFormatter}} texts with {{LogEndpoint}}.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)