Skip to content

Commit

Permalink
CAMEL-17549: log component - Add option to have it use source locatio…
Browse files Browse the repository at this point in the history
…n:line as logger name
  • Loading branch information
davsclaus committed Jan 25, 2022
1 parent 3318bdb commit eb7195b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ public Processor createChildProcessor(Route route, NamedNode definition, boolean
if (object instanceof ProcessorFactory) {
ProcessorFactory pc = (ProcessorFactory) object;
Processor processor = pc.createChildProcessor(route, definition, mandatory);
if (processor instanceof LineNumberAware) {
LineNumberAware lna = (LineNumberAware) processor;
lna.setLineNumber(definition.getLineNumber());
lna.setLocation(definition.getLocation());
}
LineNumberAware.trySetLineNumberAware(processor, definition);
return processor;
}
} catch (NoFactoryAvailableException e) {
Expand All @@ -98,14 +94,9 @@ public Processor createProcessor(Route route, NamedNode definition) throws Excep
ProcessorFactory pc = finder.newInstance(name, ProcessorFactory.class).orElse(null);
if (pc != null) {
Processor processor = pc.createProcessor(route, definition);
if (processor instanceof LineNumberAware) {
LineNumberAware lna = (LineNumberAware) processor;
lna.setLineNumber(definition.getLineNumber());
lna.setLocation(definition.getLocation());
}
LineNumberAware.trySetLineNumberAware(processor, definition);
return processor;
}

return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ public Processor createProcessor() {
ObjectHelper.notNull(definition.getRef(), "ref", definition);
answer = mandatoryLookup(definition.getRef(), Processor.class);
}

if (answer instanceof LineNumberAware) {
LineNumberAware lna = (LineNumberAware) answer;
lna.setLineNumber(definition.getLineNumber());
lna.setLocation(definition.getLocation());
}
LineNumberAware.trySetLineNumberAware(answer, definition);

// ensure its wrapped in a Service so we can manage it from eg. JMX
// (a Processor must be a Service to be enlisted in JMX)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,19 @@ protected TypedProcessorFactory(Class<T> type) {
public Processor createChildProcessor(Route route, NamedNode definition, boolean mandatory) throws Exception {
if (type.isInstance(definition)) {
Processor processor = doCreateChildProcessor(route, type.cast(definition), mandatory);
if (processor instanceof LineNumberAware) {
LineNumberAware lna = (LineNumberAware) processor;
lna.setLineNumber(definition.getLineNumber());
lna.setLocation(definition.getLocation());
}
LineNumberAware.trySetLineNumberAware(processor, definition);
return processor;
}

return null;
}

@Override
public Processor createProcessor(Route route, NamedNode definition) throws Exception {
if (type.isInstance(definition)) {
Processor processor = doCreateProcessor(route, type.cast(definition));
if (processor instanceof LineNumberAware) {
LineNumberAware lna = (LineNumberAware) processor;
lna.setLineNumber(definition.getLineNumber());
lna.setLocation(definition.getLocation());
}
LineNumberAware.trySetLineNumberAware(processor, definition);
return processor;
}

return null;
}

Expand Down

0 comments on commit eb7195b

Please sign in to comment.