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

Let logging to file respect log level #8264

Merged
merged 3 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions engine/language-server/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ logging-service {
org.eclipse.jgit = error
io.methvin.watcher = error
# Log levels to limit during very verbose setting:
#org.enso.languageserver.protocol.json.JsonConnectionController = debug
#org.enso.jsonrpc.JsonRpcServer = debug
#org.enso.languageserver.runtime.RuntimeConnector = debug
org.enso.languageserver.protocol.json.JsonConnectionController = debug
Copy link
Member

Choose a reason for hiding this comment

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

Nice to see that this is uncommented by default.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I got fed up with it. In trace you can't see anything because of it.

org.enso.jsonrpc.JsonRpcServer = debug
org.enso.languageserver.runtime.RuntimeConnector = debug
}
appenders = [
{
Expand All @@ -56,7 +56,7 @@ logging-service {
default-appender = socket
default-appender = ${?ENSO_APPENDER_DEFAULT}
log-to-file {
enable = false
enable = false ## Will have effect only if language server is not using socket appender
enable = ${?ENSO_LOG_TO_FILE}
log-level = debug
log-level = ${?ENSO_LOG_TO_FILE_LOG_LEVEL}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ public boolean setup(Level logLevel, LoggerSetup appenderSetup) {
@Override
public boolean setupForPath(
Level logLevel, Path logRoot, String logPrefix, LoggerSetup loggerSetup) {
if (loggerSetup.getConfig().logToFile().enabled()) {
loggerSetup.setupFileAppender(
loggerSetup.getConfig().logToFile().logLevel(), logRoot, logPrefix);
LogToFile logToFileOpt = loggerSetup.getConfig().logToFile();
if (logToFileOpt.enabled()) {
Level minLevel =
Level.intToLevel(Math.min(logToFileOpt.logLevel().toInt(), logLevel.toInt()));
loggerSetup.setupFileAppender(minLevel, logRoot, logPrefix);
}
return loggerSetup.setupConsoleAppender(logLevel);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ public boolean setupSocketAppender(
int port) {
Level targetLogLevel;
// Modify log level if we were asked to always log to a file.
// The receiver needs to get all logs (up to `trace`) so as to be able to log all verbose messages.
// The receiver needs to get all logs (up to `trace`) to be able to log all verbose messages.
if (logToFileEnabled()) {
int min = Math.min(Level.TRACE.toInt(), config.logToFile().logLevel().toInt());
int min = Math.min(logLevel.toInt(), config.logToFile().logLevel().toInt());
targetLogLevel = Level.intToLevel(min);
} else {
targetLogLevel = logLevel;
}
LoggerAndContext env = contextInit(targetLogLevel, config, !logToFileEnabled());
LoggerAndContext env = contextInit(targetLogLevel, config, true);

org.enso.logger.config.SocketAppender appenderConfig = config.getSocketAppender();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,17 @@ public static Future<URI> setupServer(
throw new LoggingServiceAlreadySetup();
} else {
if (config.appenders().containsKey(config.appender())) {
currentLevel = config.logToFile().enabled() ? config.logToFile().logLevel() : logLevel;
if (config.logToFile().enabled()) {
String envSetLogLevel = System.getenv("ENSO_LOG_TO_FILE_LOG_LEVEL");
if (envSetLogLevel != null) {
currentLevel = config.logToFile().logLevel();
} else {
int min = Math.min(config.logToFile().logLevel().toInt(), logLevel.toInt());
currentLevel = Level.intToLevel(min);
}
} else {
currentLevel = logLevel;
}
return Future.apply(
() -> {
var server = LoggingServiceFactory.get().localServerFor(port);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ logging-service {
max-file-size = "100MB"
max-history = 30
max-total-size = "2GB"
}
},
immediate-flush = true
},
{
name = "sentry"
Expand Down
Loading