You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fury.apache.org by ch...@apache.org on 2024/04/14 03:38:12 UTC
(incubator-fury) branch main updated: chore(java): Improve javadoc for logging module. (#1509)
This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-fury.git
The following commit(s) were added to refs/heads/main by this push:
new 21976021 chore(java): Improve javadoc for logging module. (#1509)
21976021 is described below
commit 2197602148574dc400f9b4dc2604371294b96f3c
Author: LiangliangSui <11...@users.noreply.github.com>
AuthorDate: Sun Apr 14 11:38:08 2024 +0800
chore(java): Improve javadoc for logging module. (#1509)
<!--
**Thanks for contributing to Fury.**
**If this is your first time opening a PR on fury, you can refer to
[CONTRIBUTING.md](https://github.com/apache/incubator-fury/blob/main/CONTRIBUTING.md).**
Contribution Checklist
- The **Apache Fury (incubating)** community has restrictions on the
naming of pr titles. You can also find instructions in
[CONTRIBUTING.md](https://github.com/apache/incubator-fury/blob/main/CONTRIBUTING.md).
- Fury has a strong focus on performance. If the PR you submit will have
an impact on performance, please benchmark it first and provide the
benchmark result here.
-->
## What does this PR do?
<!-- Describe the purpose of this PR. -->
Improve javadoc for logging module.
## Related issues
<!--
Is there any related issue? Please attach here.
- #xxxx0
- #xxxx1
- #xxxx2
-->
https://github.com/apache/incubator-fury/issues/1497
## Does this PR introduce any user-facing change?
<!--
If any user-facing interface changes, please [open an
issue](https://github.com/apache/incubator-fury/issues/new/choose)
describing the need to do so and update the document if necessary.
-->
- [ ] Does this PR introduce any binary protocol compatibility change?
- [ ] Does this PR introduce any public API change?
## Benchmark
<!--
When the PR has an impact on performance (if you don't know whether the
PR will have an impact on performance, you can submit the PR first, and
if it will have impact on performance, the code reviewer will explain
it), be sure to attach a benchmark data here.
-->
---------
Signed-off-by: LiangliangSui <co...@gmail.com>
---
.../java/org/apache/fury/logging/LogLevel.java | 1 +
.../org/apache/fury/logging/LoggerFactory.java | 32 +++++++++++++++++++---
2 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/java/fury-core/src/main/java/org/apache/fury/logging/LogLevel.java b/java/fury-core/src/main/java/org/apache/fury/logging/LogLevel.java
index 6e07d3de..2ca40f14 100644
--- a/java/fury-core/src/main/java/org/apache/fury/logging/LogLevel.java
+++ b/java/fury-core/src/main/java/org/apache/fury/logging/LogLevel.java
@@ -19,6 +19,7 @@
package org.apache.fury.logging;
+/** Defines a series of log levels. */
public class LogLevel {
public static final int ERROR_LEVEL = 0;
diff --git a/java/fury-core/src/main/java/org/apache/fury/logging/LoggerFactory.java b/java/fury-core/src/main/java/org/apache/fury/logging/LoggerFactory.java
index 408f9c78..c5f290f4 100644
--- a/java/fury-core/src/main/java/org/apache/fury/logging/LoggerFactory.java
+++ b/java/fury-core/src/main/java/org/apache/fury/logging/LoggerFactory.java
@@ -26,30 +26,54 @@ import org.apache.fury.util.GraalvmSupport;
*/
public class LoggerFactory {
private static volatile boolean disableLogging;
- private static volatile boolean useSlf4jlogger;
- private static volatile int logLevel = 2;
+ private static volatile boolean useSlf4jLogger;
+ private static volatile int logLevel = LogLevel.INFO_LEVEL;
+ /** Disable Logger, there will be no log output. */
public static void disableLogging() {
disableLogging = true;
}
+ /**
+ * Enable Logger. {@link FuryLogger} is used by default. You can configure whether to use {@link
+ * Slf4jLogger} through {@link LoggerFactory#createSlf4jLogger(Class)}.
+ */
public static void enableLogging() {
disableLogging = false;
}
+ /**
+ * Set the {@link FuryLogger} log output control level, the default is {@link
+ * LogLevel#INFO_LEVEL}.
+ *
+ * @param level The log control level to be set, see {@link LogLevel}.
+ */
public static void setLogLevel(int level) {
logLevel = level;
}
+ /**
+ * Set whether to use Slf4jLogging.
+ *
+ * @param useSlf4jLogging {@code true} means using {@link Slf4jLogger}, {@code false} means not
+ * using it.
+ */
public static void useSlf4jLogging(boolean useSlf4jLogging) {
- LoggerFactory.useSlf4jlogger = useSlf4jLogging;
+ LoggerFactory.useSlf4jLogger = useSlf4jLogging;
}
+ /**
+ * Get a Logger for log output.
+ *
+ * @param clazz Class of output Log.
+ * @return If the logger is disabled, {@link NilLogger} will be returned, otherwise {@link
+ * FuryLogger} or {@link Slf4jLogger} will be returned.
+ */
public static Logger getLogger(Class<?> clazz) {
if (disableLogging) {
return new FuryLogger(clazz, logLevel);
} else {
- if (GraalvmSupport.IN_GRAALVM_NATIVE_IMAGE || !useSlf4jlogger) {
+ if (GraalvmSupport.IN_GRAALVM_NATIVE_IMAGE || !useSlf4jLogger) {
return new FuryLogger(clazz, logLevel);
} else {
return createSlf4jLogger(clazz);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fury.apache.org
For additional commands, e-mail: commits-help@fury.apache.org