Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ROCKETMQ-367] Add logging component. #224

Merged
merged 27 commits into from Mar 2, 2018
Merged

Conversation

lindzh
Copy link
Contributor

@lindzh lindzh commented Feb 9, 2018

What is the purpose of the change

As logging is widely used in rocketmq such as in broker ,nameserver, client and slf4j is used as default logging module. In some cases, we want to use other logging system not slf4j, we have to merge log config file to use slf4j. In my opinion, a logging module is needed in this case.

Brief changelog

  1. Add InternalLogger use rocketmq innser usage and default logging system is slf4j.
  2. Add inner logging system for client usage.
  3. Add unit test for each component.

Verifying this change

This is a fully unit test driven PR.

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a JIRA issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ROCKETMQ-XXX] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

@lindzh lindzh changed the base branch from master to develop February 9, 2018 06:39
@coveralls
Copy link

coveralls commented Feb 9, 2018

Coverage Status

Coverage increased (+1.08%) to 41.049% when pulling 3a5ad03 on lindzh:logging into a096580 on apache:develop.

</parent>

<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need it in maven pom, that is default value

logging/pom.xml Outdated
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logback-classic dependent core, so...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This component is used in test cases for slf4j api test.

logging/pom.xml Outdated
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.4.0.Final</version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why need it? I have not found similar netty's https OS dependency build task

}

@Override
public boolean isTraceEnabled() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trace and isXXXenable, Could we remove these non-practical methods in our log module?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok,And this problem will be fix in the next commit.

import java.util.HashMap;
import java.util.Map;

public class InnerLoggerFactory extends InternalLoggerFactory {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's different between inner and internal

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internallogger is basic api used in RocketMQ modules,and InnerLogger is an impl of Internallogger

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need an InnerLoggerFactory? It seems that Slf4jLoggerFactory as the default LoggerFactory is enough.

return delimeterStartIndex >= 2 && messagePattern.charAt(delimeterStartIndex - 2) == 92;
}

private static void deeplyAppendParameter(StringBuilder sbuf, Object o, Map<Object[], Object> seenMap) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we refer other exist implementation in Apache project or other projects, if that case, we must be cautious about our license and notice files :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for reminding. license and notice files are declare in package-info.java

@vongosling
Copy link
Member

well done, glad to see much polishes in the following commits

@lizhanhui
Copy link
Contributor

BasicloggerTest should follow camel naming convention, aka, BasicLoggerTest

}
}

static boolean isEscapedDelimeter(String messagePattern, int delimeterStartIndex) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: isEscapedDelimeter --> isEscapeDelimiter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx,This will be fixed in the next commit.

import java.util.HashMap;
import java.util.Map;

public class InnerLoggerFactory extends InternalLoggerFactory {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need an InnerLoggerFactory? It seems that Slf4jLoggerFactory as the default LoggerFactory is enough.

@@ -0,0 +1,93 @@
/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that , rocketmq's module including client,broker,namesrv, dose not adopt this InternalLoggerFactory.
When and how this new module is integrated with the other modules.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Logging module,In the next PR,Slf4j api used in broker, common,remoting and other modules will be changed to InternalLoggerFactory

Copy link
Member

@zhouxinyu zhouxinyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM, please resolve the above issues.

@lindzh
Copy link
Contributor Author

lindzh commented Mar 2, 2018

@dongeforever InnerLoggerFactory is used for client logging. As slf4j log configuration file may conflict with other logging system, InnerLoggerFactory is used to solve this probelm.

@zhouxinyu zhouxinyu merged commit 305f571 into apache:develop Mar 2, 2018
@vongosling vongosling added this to the 4.3.0 milestone Jun 25, 2018
renshuaibing-aaron pushed a commit to renshuaibing-aaron/rocketmq that referenced this pull request Apr 13, 2020
JiaMingLiu93 pushed a commit to JiaMingLiu93/rocketmq that referenced this pull request May 28, 2020
lizhanhui pushed a commit to lizhanhui/rocketmq that referenced this pull request Dec 10, 2020
….rocketmq.store.CommitLog#topicQueueTable in memory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants