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 Tue, 13 Sep 2016 19:35:21 GMT

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

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

GitHub user tkopczynski opened a pull request:

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

    CAMEL-10263: Logging improvements

    This PR introduces several logging improvements as described in https://issues.apache.org/jira/browse/CAMEL-10263

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/tkopczynski/camel camel-10263

Alternatively you can review and apply these changes as the patch at:

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

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1174
    
----
commit 16716d6021e3416e78239e01dd1bcf5c56d1822e
Author: Tomasz Kopczynski <tomek@kopczynski.net.pl>
Date:   2016-09-12T21:08:17Z

    CAMEL-10263: Logging improvements

----


> 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
>            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