-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable log-to-file configuration (#7918)
* Enable log-to-file configuration PR #7825 enabled parallel logging to a file with a much more fine-grained log level by default. However, logging at `TRACE` level on Windows appears to be still problematic. This PR reduced the default log level to file from `DEBUG` to `TRACE` and allows to control it via an environment variable if one wishes to change the verbosity without making code changes. * PR comments
- Loading branch information
Showing
13 changed files
with
1,075 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
lib/scala/logging-config/src/main/java/org/enso/logger/config/LogToFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.enso.logger.config; | ||
|
||
import com.typesafe.config.Config; | ||
import org.slf4j.event.Level; | ||
|
||
/** | ||
* If `enabled`, all logs up to `logLevel` level will be persisted in the log file in parallel to the default appender. | ||
*/ | ||
public record LogToFile(boolean enabled, Level logLevel) { | ||
|
||
public static final String logToFileEnabledKey = "enable"; | ||
public static final String logToFileLogLevelKey = "log-level"; | ||
|
||
/** | ||
* Parses `log-to-file` configuration section. | ||
* | ||
* @param config application configuration section that determines logging to a file | ||
* @return parsed `log-to-file` configuration | ||
*/ | ||
public static LogToFile fromConfig(Config config) { | ||
if (config.hasPath(logToFileEnabledKey)) { | ||
Level lvl = config.hasPath(logToFileLogLevelKey) ? fromConfigValue(config.getString(logToFileLogLevelKey)) : Level.DEBUG; | ||
return new LogToFile(config.getBoolean(logToFileEnabledKey), lvl); | ||
} else { | ||
return disabled(); | ||
} | ||
} | ||
|
||
/** | ||
* Returns configuration that disables parallel logging to a file. | ||
*/ | ||
public static LogToFile disabled() { | ||
return new LogToFile(false, Level.ERROR); | ||
} | ||
|
||
private static Level fromConfigValue(String logLevel) { | ||
try { | ||
return Level.valueOf(logLevel.toUpperCase()); | ||
} catch (IllegalArgumentException iae) { | ||
return Level.DEBUG; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.