camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-10263) Several log refactoring/improvement suggestions
Date Wed, 14 Sep 2016 14:01:21 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-10263?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15490511#comment-15490511
] 

ASF GitHub Bot commented on CAMEL-10263:
----------------------------------------

Github user tkopczynski closed the pull request at:

    https://github.com/apache/camel/pull/1174


> Several log refactoring/improvement suggestions
> -----------------------------------------------
>
>                 Key: CAMEL-10263
>                 URL: https://issues.apache.org/jira/browse/CAMEL-10263
>             Project: Camel
>          Issue Type: Task
>    Affects Versions: 2.17.3
>            Reporter: Nemo Chen
>            Assignee: Andrea Cosentino
>            Priority: Trivial
>             Fix For: 2.18.0
>
>
> *method invocation replaced by variable*
> file: apache-camel-2.17.3/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogDebugger.java
> method: void beforeProcess (Exchange exchange, Processor processor, ProcessorDefinition<?>
definition)
> {code}exchangeId=exchange.getExchangeId(){code}
> {code}logger.log("NodeBreakpoint at node " + toNode + " is waiting to continue for exchangeId:
"+ exchange.getExchangeId());{code}
> file: apache-camel-2.17.3/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiCamelContextPublisher.java
> method : ServiceRegistration<?> registerCamelContext (CamelContext camelContext)
> {code}name=camelContext.getName(){code}
> {code}log.debug("Registering CamelContext [{}] of in OSGi registry",camelContext.getName());{code}
> The method invocations in above examples are assigned to variables before, we should
replace the method invocation with the variable for simpliciy and readabiliy of logs.
> ----
> *method invocation in return statement*
> file: apache-camel-2.17.3/camel-core/src/main/java/org/apache/camel/processor/aggregate/AggregateProcessor.java
> void doForceCompletionOnStop ()
> {code}LOG.trace("Waiting for {} inflight exchanges to complete",inProgressCompleteExchanges.size());{code}
> {code}
> public int getInProgressCompleteExchanges() {
>     return inProgressCompleteExchanges.size();
> }
> {code}
> file: apache-camel-2.17.3/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/DisruptorReference.java
> method:void removeEndpoint (final DisruptorEndpoint disruptorEndpoint)
> {code}LOGGER.debug("Endpoint removed: {}, new total endpoints {}",disruptorEndpoint,endpoints.size());{code}
> {code}
> public synchronized int getEndpointCount() {
>     return endpoints.size();
> }
> {code}
> file: apache-camel-2.17.3/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
> method: void configureListenerContainer (AbstractMessageListenerContainer listenerContainer,
JmsConsumer consumer)
> {code}
> log.debug("Deferring creation of TaskExecutor for listener container: {} as per policy:
{}",listenerContainer,configuration.getDefaultTaskExecutorType());
> {code}
> {code}
> @ManagedAttribute
> public DefaultTaskExecutorType getDefaultTaskExecutorType() {
>     return configuration.getDefaultTaskExecutorType();
> }
> {code}
> In the above examples, the method invocations are in the return statements of the method
in the same class. Replace the method invocations with the methods will make the log more
readable and easy to maintain.
> ----
> *Check if variable is null*
> file: apache-camel-2.17.3/components/camel-guice/src/test/java/org/apache/camel/guice/testing/InjectorManager.java
> void afterClasses ()
> {code}
> System.out.println("Could not close Class scope as there is no Injector for module type
" + injector);
> {code}
> file: apache-camel-2.17.3/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpTrapConsumer.java
> void processPdu (CommandResponderEvent event)
> {code}
> LOG.debug("Received invalid trap PDU: " + pdu);
> {code}
> In the above examples, the variable is null in the log. There is no need to print the
invalid variable in the logs. Suggestion: delete the variables in the logs to avoid confusion.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message