From aab71c4a73481ac56de7955b65cf863c65e040b7 Mon Sep 17 00:00:00 2001 From: Bartosz Firyn Date: Thu, 30 May 2019 10:36:50 +0200 Subject: [PATCH] Address code review comments in regards to log file name --- .../io/quarkus/runtime/logging/FileConfig.java | 11 ++++++++--- .../src/main/asciidoc/extension-authors-guide.adoc | 14 +++++++------- .../io/quarkus/test/common/PropertyTestUtil.java | 4 +++- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/core/runtime/src/main/java/io/quarkus/runtime/logging/FileConfig.java b/core/runtime/src/main/java/io/quarkus/runtime/logging/FileConfig.java index e300c8dac20ad3..3856c3488a1ddc 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/logging/FileConfig.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/logging/FileConfig.java @@ -27,6 +27,11 @@ @ConfigGroup public class FileConfig { + /** + * Default file name where logs should be stored. + */ + public static final String DEFAULT_LOG_FILE_NAME = "quarkus.log"; + /** * If file logging should be enabled */ @@ -40,15 +45,15 @@ public class FileConfig { String format; /** - * The file log level + * The level of logs to be written into the file. */ @ConfigItem(defaultValue = "ALL") Level level; /** - * The file logging log level + * The name of the file in which logs will be written. */ - @ConfigItem(defaultValue = "quarkus.log") + @ConfigItem(defaultValue = DEFAULT_LOG_FILE_NAME) File path; /** diff --git a/docs/src/main/asciidoc/extension-authors-guide.adoc b/docs/src/main/asciidoc/extension-authors-guide.adoc index 6f86cee7bfb838..3ad01267dddf3c 100644 --- a/docs/src/main/asciidoc/extension-authors-guide.adoc +++ b/docs/src/main/asciidoc/extension-authors-guide.adoc @@ -482,7 +482,7 @@ import java.util.logging.Level; public class FileConfig { /** - * Enable logging to file. + * Enable logging to a file. */ @ConfigItem(defaultValue = "true") boolean enable; @@ -494,13 +494,13 @@ public class FileConfig { String format; /** - * The log level. + * The level of logs to be written into the file. */ @ConfigItem(defaultValue = "ALL") Level level; /** - * The file name where logs will be stored. + * The name of the file in which logs will be written. */ @ConfigItem(defaultValue = "application.log") File path; @@ -545,9 +545,9 @@ configuration object containing a collection of configurable properties, rather key type. <2> The `@ConfigRoot` annotation indicates that this object is a configuration root group, in this case one which corresponds to a `log` segment. A class name is used to link configuration root group with the segment from a -property name. This class name is `LogConfiguration` so the `Configuration` part is stripped off, the remaining `Log` -is lowercased and becomes a `log`. Since all `@ConfigRoot` annotated classes uses `quarkus` as a prefix, this finally -becomes `quarkus.log` and represents a properties which names begins with `quarkus.log.*`. +property name. The `Configuration` part is stripped off from a `LogConfiguration` class name and the remaining `Log` +is lowercased to become a `log`. Since all `@ConfigRoot` annotated classes uses `quarkus` as a prefix, this finally +becomes `quarkus.log` and represents the properties which names begin with `quarkus.log.*`. <3> Here the `LoggingProcessor` injects a `LogConfiguration` instance automatically by detecting the `@ConfigRoot` annotation. @@ -560,7 +560,7 @@ quarkus.log.file.level=DEBUG quarkus.log.file.path=/tmp/debug.log ---- -Since `format` is not defined in these properties, a default value from `@ConfigItem` will be used instead. +Since `format` is not defined in these properties, the default value from `@ConfigItem` will be used instead. === Bytecode Recording diff --git a/test-framework/common/src/main/java/io/quarkus/test/common/PropertyTestUtil.java b/test-framework/common/src/main/java/io/quarkus/test/common/PropertyTestUtil.java index d76e2d8176e81a..7d4f2f3277fe56 100644 --- a/test-framework/common/src/main/java/io/quarkus/test/common/PropertyTestUtil.java +++ b/test-framework/common/src/main/java/io/quarkus/test/common/PropertyTestUtil.java @@ -19,6 +19,8 @@ import java.nio.file.Files; import java.nio.file.Paths; +import io.quarkus.runtime.logging.FileConfig; + public class PropertyTestUtil { public static void setLogFileProperty() { @@ -30,7 +32,7 @@ public static void setLogFileProperty(String logFileName) { } public static String getLogFileLocation() { - return getLogFileLocation("quarkus.log"); + return getLogFileLocation(FileConfig.DEFAULT_LOG_FILE_NAME); } private static String getLogFileLocation(String logFileName) {