You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by "Pil0tXia (via GitHub)" <gi...@apache.org> on 2023/12/29 17:37:57 UTC
[PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Pil0tXia opened a new pull request, #4698:
URL: https://github.com/apache/eventmesh/pull/4698
<!--
### Contribution Checklist
- Name the pull request in the form "[ISSUE #XXXX] Title of the pull request",
where *XXXX* should be replaced by the actual issue number.
Skip *[ISSUE #XXXX]* if there is no associated github issue for this pull request.
- Fill out the template below to describe the changes contributed by the pull request.
That will give reviewers the context they need to do the review.
- Each pull request should address only one issue.
Please do not mix up code from multiple issues.
- Each commit in the pull request should have a meaningful commit message.
- Once all items of the checklist are addressed, remove the above text and this checklist,
leaving only the filled out template below.
(The sections below can be removed for hotfixes of typos)
-->
<!--
(If this PR fixes a GitHub issue, please add `Fixes #<XXX>` or `Closes #<XXX>`.)
-->
Fixes #4697.
### Background Knowledge
Disscussion: https://github.com/apache/logging-log4j2/discussions/2133
The additional `isDebugEnabled()` check before `log.debug()` is performed in order to avoid invoking the methods referenced in the `message` field, thus improving logging performance. For example:
```java
log.debug("formatted msg: {}", formatMsg(rawMsg));
```
Even when the log level is set to `info`, the `formatMsg(rawMsg)` method will still be called and return a result before being passed as an argument to `log.debug()`. This takes time.
### Solution Selection
Since slf4j does not support passing arguments through the Supplier introduced in log4j 2.13.0 (discussed in https://github.com/qos-ch/slf4j/pull/70, no need to read though), we will not adopt the solution of lazy invocation by passing the Supplier parameter. Additionally, the usage of the Supplier appears redundant, and most contributors cannot understand the difference between using a Supplier or not without prior knowledge.
The [Fluent Logging API](https://www.slf4j.org/manual.html#fluent) since slf4j 2.0.0 provides a more elegant and space-saving way of writing code.
>Fluent Logging API is backward-compatible. The atTrace(), atDebug(), atInfo(), atWarn() and atError() methods, all new in the org.slf4j.Logger interface, return an instance of [LoggingEventBuilder](https://www.slf4j.org/apidocs/org/slf4j/spi/LoggingEventBuilder.html). For disabled log levels, the returned LoggingEventBuilder instance does nothing, thus preserving the nanosecond level performance of the traditional logging interface.

The modifications to the `WatchFileManager` class demonstrate the recommended approach.
### Scenarios where Fluent Logging API is unnecessary
Only the scenario mentioned in the Background Knowledge section require the use of Fluent Logging API. For example, in the case of the changes in `Codec` class L224, where no object parameters are passed or existing objects are referenced, there is no additional performance overhead, and there is no need to pre-evaluate log levels. The simplest usage of slf4j can be directly applied.
### Follow-up tasks
After adopting Fluent Logging API, there is no need to keep `LogUtils`. Going forward, @scwlkq will submit a PR for the unified modification of log output statements.
### Documentation
- Does this pull request introduce a new feature? (yes)
- If yes, how is the feature documented? (not applicable)
- If a feature is not applicable for documentation, explain why? https://www.slf4j.org/manual.html#fluent
- If a feature is not documented yet in this PR, please create a followup issue for adding the documentation
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1438520944
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/file/WatchFileManager.java:
##########
@@ -62,10 +60,10 @@ private static void shutdown() {
return;
}
- LogUtils.info(log, "[WatchFileManager] start close");
+ log.atInfo().log("[WatchFileManager] start close");
Review Comment:
@Pil0tXia
So, you were referring to the situation you initially gave as an example, rather than the case of this line of reviewed code.
原来也是指最开始您所举例的情形,而非这行被review代码的情形。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1438481651
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/file/WatchFileManager.java:
##########
@@ -62,10 +60,10 @@ private static void shutdown() {
return;
}
- LogUtils.info(log, "[WatchFileManager] start close");
+ log.atInfo().log("[WatchFileManager] start close");
Review Comment:
1. Since `log.info()` already supports determining log level internally, why not use a more concise `log.info()` instead?
2. Why not use the solution provided by @ppkarwasz in the [discussion](https://github.com/apache/logging-log4j2/discussions/2133) to modify LogUtils? Isn't this change smaller?
```
private static final String FQCN = LogUtils.class.getName():
public static void trace(Logger logger, Marker marker, String msg, Object arg) {
final LoggingEventBuilder builder = logger.atTrace();
if (builder instanceof CallerBoundaryAware) {
((CallerBoundaryAware) builder).setCallerBoundary(FQCN);
}
builder.addMarker(marker).log(msg, arg);
}
```
---
1. 既然`log.info()`内部已经支持判断日志级别,为什么不直接使用更简洁的`log.info()`?
2. 为什么不采用[讨论](https://github.com/apache/logging-log4j2/discussions/2133)中 ppkarwasz 提供的这种方案修改下LogUtils,这样改动不是更小吗?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1438507616
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/codec/Codec.java:
##########
@@ -161,7 +159,7 @@ private Header parseHeader(ByteBuf in, int headerLength) throws JsonProcessingEx
}
final byte[] headerData = new byte[headerLength];
in.readBytes(headerData);
- LogUtils.debug(log, "Decode headerJson={}", deserializeBytes(headerData));
+ log.atDebug().log("Decode headerJson={}", deserializeBytes(headerData));
Review Comment:
> True🤣I tested it with the code below, and the timer shows that only Supplier could avoid executing `formatMsg()`. However the Fluent API said that `For disabled log levels, the returned LoggingEventBuilder instance does nothing`. Why is that?
This is due to the order in which Java evaluates methods: it always evaluates the arguments of a method before the method itself. In this concrete example:
```java
log.atDebug().log("Decode headerJson={}", deserializeBytes(headerData));
```
Java will:
1. Call `Logger#atDebug()` and obtain a `NOPLoggingEventBuilder`,
2. Call `deserializeBytes` and obtain a string,
3. Call `NOPLoggingEventBuilder#log` which does nothing.
The [Scala language](https://docs.scala-lang.org/tour/by-name-parameters.html) has call-by-name arguments that are evaluated only if they are used. In Java everything is call-by-value and the arguments are computed even if they are not used.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1443639011
##########
build.gradle:
##########
@@ -40,15 +40,6 @@ buildscript {
}
}
-//Remove doclint warnings that pollute javadoc logs when building with java8
-if(JavaVersion.current().isJava8()){
Review Comment:
JDK11 failed to execute task `javadoc` (c.f. https://github.com/apache/eventmesh/actions/runs/7406186071/job/20162982838), because of the JavaDoc I wrote in https://github.com/apache/eventmesh/pull/4698/commits/7c1c2ddb72a47fb30ffe4a98a4ac88e69a283088.
I had a re-check and it seems that I have to and another code tag to make JDK11 javadoc build success:

During my troubleshooting process, I noticed that the `javadoc.options` file does not provide any useful information, which led me to test the reason for needing a closing `</p>` tag or indentation or other issues. It was quite time-consuming.
[javadoc.options.txt](https://github.com/apache/eventmesh/files/13848546/javadoc.options.txt)
In your opinion, do you think it would be better to keep the javadoc task settings as they are, only effective for JDK 8, or would it be better to remove the "if" condition for JDK 8?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1443634446
##########
eventmesh-sdks/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/producer/EventMeshGrpcProducer.java:
##########
@@ -61,7 +61,7 @@ public EventMeshGrpcProducer(EventMeshGrpcClientConfig clientConfig) {
}
public <T> Response publish(T message) {
- LogUtils.info(log, "Publish message ", message.toString());
+ LogUtil.info(log, "Publish message ", message::toString);
Review Comment:
The supplier can be processed correctly:

However, due to an incorrect modification, the supplier parameter does not have a place to be filled:

I will correct similar usages. @scwlkq Please have a check.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#issuecomment-1886694902
Conflicts resolved. @pandaapo May you please approve? Thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1443646556
##########
eventmesh-webhook/eventmesh-webhook-receive/src/main/java/org/apache/eventmesh/webhook/receive/WebHookController.java:
##########
@@ -123,12 +123,12 @@ public void execute(String path, Map<String, String> header, byte[] body) throws
@Override
public void onSuccess(SendResult sendResult) {
- LogUtils.debug(log, sendResult.toString());
+ LogUtil.debug(log, "", sendResult::toString);
Review Comment:
Adding a `builder.addArgument(objectSupplier).log();` will output `null`, so I added a `{}` in https://github.com/apache/eventmesh/pull/4698/commits/abc67cedbc2259ad1f503842138d27fa02fa0e2a.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "xwm1992 (via GitHub)" <gi...@apache.org>.
xwm1992 commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1441787627
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/file/WatchFileManager.java:
##########
@@ -62,10 +60,10 @@ private static void shutdown() {
return;
}
- LogUtils.info(log, "[WatchFileManager] start close");
+ log.atInfo().log("[WatchFileManager] start close");
Review Comment:
这里的性能会更好,应该还是部分特殊的情况(适用于能够懒加载的情况),既然LogUtils能解决日志代码行显示的问题,我觉得也可以采用LogUtils统一封装一下,这样在编码风格上也能有一定的统一。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1443628305
##########
build.gradle:
##########
@@ -94,6 +85,10 @@ allprojects {
.exclude('**/org/apache/eventmesh/connector/openfunction/client/CallbackServiceGrpc**')
.exclude('**/org/apache/eventmesh/connector/jdbc/antlr**')
+ configurations {
+ errorprone.extendsFrom(annotationProcessor)
Review Comment:
👌, then we can search for errorprone in Github PRs for reference.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1444503337
##########
build.gradle:
##########
@@ -40,15 +40,6 @@ buildscript {
}
}
-//Remove doclint warnings that pollute javadoc logs when building with java8
-if(JavaVersion.current().isJava8()){
Review Comment:
For now, the `javadoc` task remains original. Only executed under JDK8 will surpress `javadoc` warnings.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#issuecomment-1872293520
@g0715158 pulsar connector introduced log4j-slf4j-impl-2.18.0.jar.
@yanrongzhen spring connector introduced log4j-to-slf4j-2.17.1.jar and log4j-slf4j-impl
log4j-slf4j-impl can't be used together with log4j-to-slf4j according to https://logging.apache.org/log4j/2.x/log4j-slf4j-impl.html. May you please have a check and exclude `log4j-to-slf4j` if possible?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1438503329
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/codec/Codec.java:
##########
@@ -161,7 +159,7 @@ private Header parseHeader(ByteBuf in, int headerLength) throws JsonProcessingEx
}
final byte[] headerData = new byte[headerLength];
in.readBytes(headerData);
- LogUtils.debug(log, "Decode headerJson={}", deserializeBytes(headerData));
+ log.atDebug().log("Decode headerJson={}", deserializeBytes(headerData));
Review Comment:
True🤣I tested it with the code below, and the timer shows that only Supplier could avoid executing `formatMsg()`. However the Fluent API said that `For disabled log levels, the returned LoggingEventBuilder instance does nothing`. Why is that?
Test code, ran under `debug` level:
```
......
long traceStart = System.currentTimeMillis();
log.trace("log.trace(). formatMsg() return value: {}", formatMsg("log.trace()", "executed"));
long traceEnd = System.currentTimeMillis();
long atTraceStart = System.currentTimeMillis();
log.atTrace().log("log.atTrace().log(). formatMsg() return value: {}", formatMsg("log.atTrace().log()", "executed"));
long atTraceEnd = System.currentTimeMillis();
long atTraceSupplierStart = System.currentTimeMillis();
log.atTrace().addArgument(() -> formatMsg("log.atTrace() Supplier", "executed")).log("log.atTrace().addArgument().log()");
long atTraceSupplierEnd = System.currentTimeMillis();
log.info("log.trace() cost: {}ms, log.atTrace().log() cost: {}ms, log.atTrace() Supplier cost: {}ms",
traceEnd - traceStart, atTraceEnd - atTraceStart, atTraceSupplierEnd - atTraceSupplierStart);
}
private String formatMsg(String name, String status) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
return name + "-" + status;
}
```
Output:
```
log.trace() cost: 1009ms, log.atTrace().log() cost: 1002ms, log.atTrace() Supplier cost: 0ms
```
`addArgument` is really inconvenient; it is less convenient than using `ifDebugEnabled`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#issuecomment-1872482856
Thanks @ppkarwasz @pandaapo , let's use LogUtils.
```java
public static void trace(Logger logger, String msg, Object arg) {
final LoggingEventBuilder builder = logger.atTrace();
if (builder instanceof CallerBoundaryAware) {
((CallerBoundaryAware) builder).setCallerBoundary(FQCN);
}
builder.log(msg, arg);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1438503329
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/codec/Codec.java:
##########
@@ -161,7 +159,7 @@ private Header parseHeader(ByteBuf in, int headerLength) throws JsonProcessingEx
}
final byte[] headerData = new byte[headerLength];
in.readBytes(headerData);
- LogUtils.debug(log, "Decode headerJson={}", deserializeBytes(headerData));
+ log.atDebug().log("Decode headerJson={}", deserializeBytes(headerData));
Review Comment:
True🤣I tested it with the code below, and the timer shows that only Supplier could avoid executing `formatMsg()`. However the Fluent API said that `For disabled log levels, the returned LoggingEventBuilder instance does nothing`. Why is that?
Test code, ran under `debug` level:
```
......
long traceStart = System.currentTimeMillis();
log.trace("log.trace(). formatMsg() return value: {}", formatMsg("log.trace()", "executed"));
long traceEnd = System.currentTimeMillis();
long atTraceStart = System.currentTimeMillis();
log.atTrace().log("log.atTrace().log(). formatMsg() return value: {}", formatMsg("log.atTrace().log()", "executed"));
long atTraceEnd = System.currentTimeMillis();
long atTraceSupplierStart = System.currentTimeMillis();
log.atTrace().addArgument(() -> formatMsg("log.atTrace() Supplier", "executed")).log("log.atTrace().addArgument().log()");
long atTraceSupplierEnd = System.currentTimeMillis();
log.info("log.trace() cost: {}ms, log.atTrace().log() cost: {}ms, log.atTrace() Supplier cost: {}ms",
traceEnd - traceStart, atTraceEnd - atTraceStart, atTraceSupplierEnd - atTraceSupplierStart);
}
private String formatMsg(String name, String status) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
return name + "-" + status;
}
```
Output:
```
log.trace() cost: 1009ms, log.atTrace().log() cost: 1002ms, log.atTrace() Supplier cost: 0ms
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1438503722
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/file/WatchFileManager.java:
##########
@@ -62,10 +60,10 @@ private static void shutdown() {
return;
}
- LogUtils.info(log, "[WatchFileManager] start close");
+ log.atInfo().log("[WatchFileManager] start close");
Review Comment:
> There are many places where the usage of `ifDebugEnabled` is a remnant from the log4j era, which can be replaced with `log.debug()` from slf4j. However, in many cases, removing the `ifDebugEnabled` directly would result in a performance decrease.
To be precise it is a remnant of the Log4j 1.x/JCL era. Since the release of SLF4J in 2005 these guards are not necessary. The Log4j 2.x API (2014) works the same way as SLF4J.
> 2.
> That requires obtaining the Fully Qualified Class Name (FQCN) of each class and passing it as a parameter to LogUtils, which is not a good approach for us.
Probably my explanations were not clear. The FQCN to use is that of the `LogUtils` class, i.e. "org.apache.eventmesh.common.utils.LogUtils". The logging backend will look into the stack for the class that **called** `LogUtils`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1438494674
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/file/WatchFileManager.java:
##########
@@ -62,10 +60,10 @@ private static void shutdown() {
return;
}
- LogUtils.info(log, "[WatchFileManager] start close");
+ log.atInfo().log("[WatchFileManager] start close");
Review Comment:
1.
- Better performance:
>The additional `isDebugEnabled()` check before `log.debug()` is performed in order to avoid invoking the methods referenced in the `message` field, thus improving logging performance. For example:
>
>```java
>log.debug("formatted msg: {}", formatMsg(rawMsg));
>```
>
>Even when the log level is set to `info`, the `formatMsg(rawMsg)` method will still be called and return a result before being passed as an argument to `log.debug()`. This takes time.
- Scenarios where Fluent Logging API is unnecessary:
>Only the scenario mentioned in the Background Knowledge section require the use of Fluent Logging API. For example, in the case of the changes in `Codec` class L224, where no object parameters are passed or existing objects are referenced, there is no additional performance overhead, and there is no need to pre-evaluate log levels. The `log.debug()` usage can be directly applied.
There are many places where the usage of `ifDebugEnabled` is a remnant from the log4j era, which can be replaced with `log.debug()` from slf4j. However, in many cases, removing the `ifDebugEnabled` directly would result in a performance decrease.
---
有不少地方的`ifDebugEnabled`是log4j时代残留的用法,可以用slf4j的`log.debug()`代替。不过也有很多地方,直接去掉`ifDebugEnabled`的话,是会降低性能的。
2.
That requires obtaining the Fully Qualified Class Name (FQCN) of each class and passing it as a parameter to LogUtils, which is not a good approach for us.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1438504051
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/file/WatchFileManager.java:
##########
@@ -62,10 +60,10 @@ private static void shutdown() {
return;
}
- LogUtils.info(log, "[WatchFileManager] start close");
+ log.atInfo().log("[WatchFileManager] start close");
Review Comment:
1.
> Better performance
Regarding "better performance", the code here does not have the same situation as the example you provided.
> However, in many cases, removing the `ifDebugEnabled` directly would result in a performance decrease.
Could you provide some examples to illustrate the performance decrease after removing the `ifDebugEnabled` you mentioned here?
Also, I don't quite understand what you mean by "removing the `ifDebugEnabled`". What is the relationship between log.debug() internal supporting for determining log level and "removing the `ifDebugEnabled`"?
2.
> That requires obtaining the Fully Qualified Class Name (FQCN) of each class and passing it as a parameter to LogUtils
The fact seems to be different.
---
1.
> However, in many cases, removing the `ifDebugEnabled` directly would result in a performance decrease.
关于“性能更好”,这里的代码不存在您所举例的情况。
> However, in many cases, removing the `ifDebugEnabled` directly would result in a performance decrease.
能否列举一些情况说明一下您这句所说的性能降低的情况?
另外,我不太明白您说的“removing the `ifDebugEnabled`”。log.debug()内部已经支持判断日志级别,这和“removing the `ifDebugEnabled`”有什么关系?
2.
> That requires obtaining the Fully Qualified Class Name (FQCN) of each class and passing it as a parameter to LogUtils
好像并非如此。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1443612429
##########
build.gradle:
##########
@@ -40,15 +40,6 @@ buildscript {
}
}
-//Remove doclint warnings that pollute javadoc logs when building with java8
-if(JavaVersion.current().isJava8()){
Review Comment:
Does Java 11 still supports `doclint`?
##########
eventmesh-webhook/eventmesh-webhook-receive/src/main/java/org/apache/eventmesh/webhook/receive/WebHookController.java:
##########
@@ -123,12 +123,12 @@ public void execute(String path, Map<String, String> header, byte[] body) throws
@Override
public void onSuccess(SendResult sendResult) {
- LogUtils.debug(log, sendResult.toString());
+ LogUtil.debug(log, "", sendResult::toString);
Review Comment:
These parameters are passed to `builder.addArgument(sendResult::toString).log("")`, how will the return value of `sendResult::toString` be output after processing?
这样的参数,经过`builder.addArgument(sendResult::toString).log("")`处理后,`sendResult::toString`的返回值会如何被输出?
##########
eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java:
##########
@@ -330,15 +330,15 @@ public boolean commitOffsets() {
log.info("{} Committing offsets for {} acknowledged messages", this, committableOffsets.numCommittableMessages());
if (committableOffsets.hasPending()) {
log.debug("{} There are currently {} pending messages spread across {} source partitions whose offsets will not be committed. "
- + "The source partition with the most pending messages is {}, with {} pending messages",
+ + "The source partition with the most pending messages is {}, with {} pending messages",
Review Comment:
Bring a situation unrelated to the purpose of this PR to the attention of the community: the automatic modification of this format seems to create a burden of constant modification, such as this line starting with no indentation, then adding indentation, and now removing indentation again.
一个和本PR目标无关的情况,提出来让社区注意一下:这种格式的自动修改,似乎带来一种改来改去的情况,比如这一行开始没有缩进,然后加上了缩进,现在移除了缩进。
##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractTCPServer.java:
##########
@@ -81,6 +80,8 @@
@Slf4j
public class AbstractTCPServer extends AbstractRemotingServer {
+ private static final Logger MESSAGE_LOGGER = LoggerFactory.getLogger(EventMeshConstants.MESSAGE);
Review Comment:
Can this field be kept in `TcpDispatcher`?
##########
eventmesh-sdks/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/producer/EventMeshGrpcProducer.java:
##########
@@ -61,7 +61,7 @@ public EventMeshGrpcProducer(EventMeshGrpcClientConfig clientConfig) {
}
public <T> Response publish(T message) {
- LogUtils.info(log, "Publish message ", message.toString());
+ LogUtil.info(log, "Publish message ", message::toString);
Review Comment:
There is no placeholder `{}`, After processed by ` builder. addArgument (message::toString). log("xxx")`, how will the return value of `message::toString` be output?
没有占位符`{}`,经过`builder.addArgument(sendResult::toString).log(xxx);`处理后,`message::toString`返回值会如何被输出?
##########
build.gradle:
##########
@@ -94,6 +85,10 @@ allprojects {
.exclude('**/org/apache/eventmesh/connector/openfunction/client/CallbackServiceGrpc**')
.exclude('**/org/apache/eventmesh/connector/jdbc/antlr**')
+ configurations {
+ errorprone.extendsFrom(annotationProcessor)
Review Comment:
For all integration code related to Error Prone, I suggest not adding code that is currently not used.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1443969876
##########
.gitignore:
##########
@@ -23,7 +23,6 @@ classes
package-lock.json
node_modules
.run
-*.log
Review Comment:
What is the reason for deleting this ignored file?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1438512107
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/file/WatchFileManager.java:
##########
@@ -62,10 +60,10 @@ private static void shutdown() {
return;
}
- LogUtils.info(log, "[WatchFileManager] start close");
+ log.atInfo().log("[WatchFileManager] start close");
Review Comment:
>removing the `ifDebugEnabled`
From:
```java
if (log.isDebugEnabled()) {
log.debug("Encoder pkg={}", JsonUtils.toJSONString(pkg));
}
```
To:
```java
log.debug("Encoder pkg={}", JsonUtils.toJSONString(pkg));
```
Even if the log level is set to "info", the latter will still invoke and execute toJSONString, whereas the former will not.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#issuecomment-1886722211
I am waiting for @xwm1992 's response to this situation. https://github.com/apache/eventmesh/pull/4698#pullrequestreview-1808499462
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1443639011
##########
build.gradle:
##########
@@ -40,15 +40,6 @@ buildscript {
}
}
-//Remove doclint warnings that pollute javadoc logs when building with java8
-if(JavaVersion.current().isJava8()){
Review Comment:
JDK11 failed to execute task `javadoc` (c.f. https://github.com/apache/eventmesh/actions/runs/7406186071/job/20162982838), because of the JavaDoc I wrote in https://github.com/apache/eventmesh/pull/4698/commits/7c1c2ddb72a47fb30ffe4a98a4ac88e69a283088.
I had a re-check and it seems that I have to and another code tag to make JDK11 javadoc build success:

There is no visible difference between the original and modified JavaDocs in IDEA's reading mode. The differences may be in the generated webpages.
During my troubleshooting process, I noticed that the `javadoc.options` file does not provide any useful information, which led me to test the reason for needing a closing `</p>` tag or indentation or other issues. It was quite time-consuming.
[javadoc.options.txt](https://github.com/apache/eventmesh/files/13848546/javadoc.options.txt)
In your opinion, do you think it would be better to keep the javadoc task settings as they are, only effective for JDK 8, or would it be better to remove the "if" condition for JDK 8?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1443628365
##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractTCPServer.java:
##########
@@ -81,6 +80,8 @@
@Slf4j
public class AbstractTCPServer extends AbstractRemotingServer {
+ private static final Logger MESSAGE_LOGGER = LoggerFactory.getLogger(EventMeshConstants.MESSAGE);
Review Comment:
A static member in subclasses is not supported util JDK16.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1438494674
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/file/WatchFileManager.java:
##########
@@ -62,10 +60,10 @@ private static void shutdown() {
return;
}
- LogUtils.info(log, "[WatchFileManager] start close");
+ log.atInfo().log("[WatchFileManager] start close");
Review Comment:
1.
- Better performance:
>The additional `isDebugEnabled()` check before `log.debug()` is performed in order to avoid invoking the methods referenced in the `message` field, thus improving logging performance. For example:
>
>```java
>log.debug("formatted msg: {}", formatMsg(rawMsg));
>```
>
>Even when the log level is set to `info`, the `formatMsg(rawMsg)` method will still be called and return a result before being passed as an argument to `log.debug()`. This takes time.
- Scenarios where Fluent Logging API is unnecessary:
>Only the scenario mentioned in the Background Knowledge section require the use of Fluent Logging API. For example, in the case of the changes in `Codec` class L224, where no object parameters are passed or existing objects are referenced, there is no additional performance overhead, and there is no need to pre-evaluate log levels. The `log.debug()` usage can be directly applied.
There are many places where the usage of `ifDebugEnabled` is a remnant from the log4j era, which can be replaced with `log.debug()` from slf4j. However, in many cases, removing the `ifDebugEnabled` directly would result in a performance decrease.
——————
有不少地方的`ifDebugEnabled`是log4j时代残留的用法,可以用slf4j的`log.debug()`代替。不过也有很多地方,直接去掉`ifDebugEnabled`的话,是会降低性能的。
2.
That requires obtaining the Fully Qualified Class Name (FQCN) of each class and passing it as a parameter to LogUtils, which is not a good approach for us.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1438481651
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/file/WatchFileManager.java:
##########
@@ -62,10 +60,10 @@ private static void shutdown() {
return;
}
- LogUtils.info(log, "[WatchFileManager] start close");
+ log.atInfo().log("[WatchFileManager] start close");
Review Comment:
1. Since `log.info()` already supports determining log level internally, why not use a more concise `log.info()` instead?
2. Why not use the solution provided by @ppkarwasz in the [discussion](https://github.com/apache/logging-log4j2/discussions/2133) to modify LogUtils? Isn't this change smaller?
```
private static final String FQCN = LogUtils.class.getName():
public static void trace(Logger logger, Marker marker, String msg, Object arg) {
final LoggingEventBuilder builder = logger.atTrace();
if (builder instanceof CallerBoundaryAware) {
((CallerBoundaryAware) builder).setCallerBoundary(FQCN);
}
builder.addMarker(marker).log(msg, arg);
}
```
---
1. 既然`log.info()`内部已经支持判断日志级别,为什么不直接使用更简洁的`log.info()`?
2. 为什么不采用[讨论](https://github.com/apache/logging-log4j2/discussions/2133)中 ppkarwasz 提供的这种方案修改下LogUtils,这样改动不是更小吗?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1443652787
##########
eventmesh-sdks/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/producer/EventMeshGrpcProducer.java:
##########
@@ -61,7 +61,7 @@ public EventMeshGrpcProducer(EventMeshGrpcClientConfig clientConfig) {
}
public <T> Response publish(T message) {
- LogUtils.info(log, "Publish message ", message.toString());
+ LogUtil.info(log, "Publish message ", message::toString);
Review Comment:
All fixed in https://github.com/apache/eventmesh/pull/4698/commits/56b3d16d8eeda594385586856bfc4bfa51a5ef97.

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#issuecomment-1874810330
## [Codecov](https://app.codecov.io/gh/apache/eventmesh/pull/4698?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
Attention: `159 lines` in your changes are missing coverage. Please review.
> Comparison is base [(`bd2aeb9`)](https://app.codecov.io/gh/apache/eventmesh/commit/bd2aeb91c5169ef04b27845c77970a52eae068c9?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) 17.39% compared to head [(`7c1c2dd`)](https://app.codecov.io/gh/apache/eventmesh/pull/4698?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) 17.33%.
> Report is 2 commits behind head on master.
| [Files](https://app.codecov.io/gh/apache/eventmesh/pull/4698?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...va/org/apache/eventmesh/common/utils/LogUtils.java](https://app.codecov.io/gh/apache/eventmesh/pull/4698?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2NvbW1vbi91dGlscy9Mb2dVdGlscy5qYXZh) | 4.24% | [155 Missing and 3 partials :warning: ](https://app.codecov.io/gh/apache/eventmesh/pull/4698?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...che/eventmesh/common/protocol/tcp/codec/Codec.java](https://app.codecov.io/gh/apache/eventmesh/pull/4698?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2NvbW1vbi9wcm90b2NvbC90Y3AvY29kZWMvQ29kZWMuamF2YQ==) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/eventmesh/pull/4698?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #4698 +/- ##
============================================
- Coverage 17.39% 17.33% -0.07%
+ Complexity 1759 1758 -1
============================================
Files 797 797
Lines 29850 29948 +98
Branches 2579 2605 +26
============================================
- Hits 5192 5191 -1
- Misses 24177 24277 +100
+ Partials 481 480 -1
```
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/eventmesh/pull/4698?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1443635031
##########
eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java:
##########
@@ -330,15 +330,15 @@ public boolean commitOffsets() {
log.info("{} Committing offsets for {} acknowledged messages", this, committableOffsets.numCommittableMessages());
if (committableOffsets.hasPending()) {
log.debug("{} There are currently {} pending messages spread across {} source partitions whose offsets will not be committed. "
- + "The source partition with the most pending messages is {}, with {} pending messages",
+ + "The source partition with the most pending messages is {}, with {} pending messages",
Review Comment:
Our community has always preferred using 1TAB instead of 2TAB, and my IDEA's default newline indentation is also 1TAB. This time, spotless mainly formatted the code for lark and wecom connector.
It appears that the checkstyle XML file in the "style" directory does not enforce 1TAB indentation for line breaks, but spotless does.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1443635031
##########
eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java:
##########
@@ -330,15 +330,15 @@ public boolean commitOffsets() {
log.info("{} Committing offsets for {} acknowledged messages", this, committableOffsets.numCommittableMessages());
if (committableOffsets.hasPending()) {
log.debug("{} There are currently {} pending messages spread across {} source partitions whose offsets will not be committed. "
- + "The source partition with the most pending messages is {}, with {} pending messages",
+ + "The source partition with the most pending messages is {}, with {} pending messages",
Review Comment:
Our community has always preferred using 1TAB instead of 2TAB, and my IDEA's default newline indentation is also 1TAB. This time, spotless mainly formatted the code for lark and wecom connector.
It appears that the checkstyle XML file in the "style" directory does not enforce 1TAB indentation for line breaks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1443635031
##########
eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java:
##########
@@ -330,15 +330,15 @@ public boolean commitOffsets() {
log.info("{} Committing offsets for {} acknowledged messages", this, committableOffsets.numCommittableMessages());
if (committableOffsets.hasPending()) {
log.debug("{} There are currently {} pending messages spread across {} source partitions whose offsets will not be committed. "
- + "The source partition with the most pending messages is {}, with {} pending messages",
+ + "The source partition with the most pending messages is {}, with {} pending messages",
Review Comment:
Our community has always preferred using 1TAB instead of 2TAB, and my IDEA's default newline indentation is also 1TAB. This time, spotless mainly formatted the code for lark and wecom connector.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1443652787
##########
eventmesh-sdks/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/producer/EventMeshGrpcProducer.java:
##########
@@ -61,7 +61,7 @@ public EventMeshGrpcProducer(EventMeshGrpcClientConfig clientConfig) {
}
public <T> Response publish(T message) {
- LogUtils.info(log, "Publish message ", message.toString());
+ LogUtil.info(log, "Publish message ", message::toString);
Review Comment:
All fixed in https://github.com/apache/eventmesh/pull/4698/commits/56b3d16d8eeda594385586856bfc4bfa51a5ef97.

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo merged PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1438492842
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/file/WatchFileManager.java:
##########
@@ -62,10 +60,10 @@ private static void shutdown() {
return;
}
- LogUtils.info(log, "[WatchFileManager] start close");
+ log.atInfo().log("[WatchFileManager] start close");
Review Comment:
1. Since `log.info()` already supports determining log level internally, why not use a more concise `log.info()` here?
2. Why not use the solution provided by @ppkarwasz in the [discussion](https://github.com/apache/logging-log4j2/discussions/2133) to modify LogUtils? Isn't this change smaller?
```
private static final String FQCN = LogUtils.class.getName():
public static void trace(Logger logger, Marker marker, String msg, Object arg) {
final LoggingEventBuilder builder = logger.atTrace();
if (builder instanceof CallerBoundaryAware) {
((CallerBoundaryAware) builder).setCallerBoundary(FQCN);
}
builder.addMarker(marker).log(msg, arg);
}
```
---
1. 既然`log.info()`内部已经支持判断日志级别,为什么这里不直接使用更简洁的`log.info()`?
2. 为什么不采用[讨论](https://github.com/apache/logging-log4j2/discussions/2133)中 ppkarwasz 提供的这种方案修改下LogUtils,这样改动不是更小吗?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1438512107
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/file/WatchFileManager.java:
##########
@@ -62,10 +60,10 @@ private static void shutdown() {
return;
}
- LogUtils.info(log, "[WatchFileManager] start close");
+ log.atInfo().log("[WatchFileManager] start close");
Review Comment:
>removing the `ifDebugEnabled`
From:
```java
if (log.isDebugEnabled()) {
log.debug("Encoder pkg={}", JsonUtils.toJSONString(pkg));
}
```
To:
```java
log.debug("Encoder pkg={}", JsonUtils.toJSONString(pkg));
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia closed pull request #4698: [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging
URL: https://github.com/apache/eventmesh/pull/4698
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1438444980
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/codec/Codec.java:
##########
@@ -171,7 +169,7 @@ private Object parseBody(ByteBuf in, Header header, int bodyLength) throws JsonP
}
final byte[] bodyData = new byte[bodyLength];
in.readBytes(bodyData);
- LogUtils.debug(log, "Decode bodyJson={}", deserializeBytes(bodyData));
+ log.atDebug().log("Decode bodyJson={}", deserializeBytes(bodyData));
Review Comment:
```suggestion
log.atDebug().addArgument(() -> deserializeBytes(bodyData)).log("Decode bodyJson={}");
```
Same as above.
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/codec/Codec.java:
##########
@@ -161,7 +159,7 @@ private Header parseHeader(ByteBuf in, int headerLength) throws JsonProcessingEx
}
final byte[] headerData = new byte[headerLength];
in.readBytes(headerData);
- LogUtils.debug(log, "Decode headerJson={}", deserializeBytes(headerData));
+ log.atDebug().log("Decode headerJson={}", deserializeBytes(headerData));
Review Comment:
```suggestion
log.atDebug().addArgument(() -> deserializeBytes(headerData)).log("Decode headerJson={}");
```
Since the purpose of your PR is to prevent expensive computations of disabled log statement arguments, you should use a lambda here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1438512107
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/file/WatchFileManager.java:
##########
@@ -62,10 +60,10 @@ private static void shutdown() {
return;
}
- LogUtils.info(log, "[WatchFileManager] start close");
+ log.atInfo().log("[WatchFileManager] start close");
Review Comment:
@pandaapo
>removing the `ifDebugEnabled`
From:
```java
if (log.isDebugEnabled()) {
log.debug("Encoder pkg={}", JsonUtils.toJSONString(pkg));
}
```
To:
```java
log.debug("Encoder pkg={}", JsonUtils.toJSONString(pkg));
```
Even if the log level is set to "info", the latter will still invoke and execute toJSONString, whereas the former will not.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#issuecomment-1878642878
@xwm1992 @pandaapo
I have streamlined `LogUtil` to support only lazy-loading methods with Supplier. Now LogUtil only has 9 overloaded methods.
There are 9 instances where the logger with time-consuming methods as parameters is replaced with LogUtil's Supplier. You can search for `LogUtil.` to find their usages.
All other usages have been replaced with regular Slf4j usage and no further work is required.
Besides, I have [Replaced isXXXXEnabled to normal use](https://github.com/apache/eventmesh/pull/4698/commits/40a16060a329856f0762a039f4ea294519b0117e), [Renamed messageLogger to static final MESSAGE_LOGGER](https://github.com/apache/eventmesh/pull/4698/commits/45028a591a2b2a5d159aa89eff8b16f6db840ddd), and [ran spotlessApply](https://github.com/apache/eventmesh/pull/4698/commits/ef7292d15434baf4e3da02b40d8d3e3f8ca97920).
[ErrorProne task](https://github.com/apache/eventmesh/pull/4698/commits/3e4dc1183f7e70d9601f48342af4939b1a4b0094) may be used in a future refactor, so I retained it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4697] Use Fluent Logging API to provide accurate, concise, and elegant logging (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4698:
URL: https://github.com/apache/eventmesh/pull/4698#discussion_r1443981182
##########
.gitignore:
##########
@@ -23,7 +23,6 @@ classes
package-lock.json
node_modules
.run
-*.log
Review Comment:
It duplicates with L11:
https://github.com/apache/eventmesh/blob/8eb3d454d022acad3cc02a4b0d461b9963d07ef7/.gitignore#L11-L12
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org