Skip to content

Commit

Permalink
Bring back jul's formatting to runtime
Browse files Browse the repository at this point in the history
Conversion of raw messages to slf4j's style is now done in the handler.
  • Loading branch information
hubertp committed Aug 14, 2023
1 parent 8e33173 commit d844b56
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 22 deletions.
4 changes: 2 additions & 2 deletions engine/runtime/src/main/java/org/enso/compiler/Cache.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ private Optional<T> loadCacheFrom(
if (cachedObject != null) {
return Optional.of(cachedObject);
} else {
logger.log(logLevel, "`{}` was corrupt on disk.", logName);
logger.log(logLevel, "`{0}` was corrupt on disk.", logName);
invalidateCache(cacheRoot, logger);
return Optional.empty();
}
Expand All @@ -275,7 +275,7 @@ private Optional<T> loadCacheFrom(
return Optional.empty();
}
} else {
logger.log(logLevel, "One or more digests did not match for the cache for [{}].", logName);
logger.log(logLevel, "One or more digests did not match for the cache for [{0}].", logName);
invalidateCache(cacheRoot, logger);
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void shutdown() {
success = false;
}
if (!success) {
context.getLogger().log(Level.WARNING, "Cannot shutdown {} thread pool", next.getValue());
context.getLogger().log(Level.WARNING, "Cannot shutdown {0} thread pool", next.getValue());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Compiler(
if (!builtins.isIrInitialized) {
context.log(
Compiler.defaultLogLevel,
"Initialising IR for [{}].",
"Initialising IR for [{0}].",
builtins.getModule.getName
)

Expand Down Expand Up @@ -432,7 +432,7 @@ class Compiler(
if (generateCode) {
context.log(
Compiler.defaultLogLevel,
"Generating code for module [{}].",
"Generating code for module [{0}].",
context.getModuleName(module)
)

Expand Down Expand Up @@ -587,7 +587,7 @@ class Compiler(
): Unit = {
context.log(
Compiler.defaultLogLevel,
"Parsing module [{}].",
"Parsing module [{0}].",
context.getModuleName(module)
)
context.updateModule(module, _.resetScope)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ final class SerializationManager(
): Future[Boolean] = {
compiler.context.logSerializationManager(
debugLogLevel,
"Requesting serialization for module [{}].",
"Requesting serialization for module [{0}].",
module.getName
)
val duplicatedIr = compiler.updateMetadata(
Expand Down Expand Up @@ -142,7 +142,7 @@ final class SerializationManager(
): Future[Boolean] = {
compiler.context.logSerializationManager(
Level.INFO,
"Requesting serialization for library [{}].",
"Requesting serialization for library [{0}].",
libraryName
)

Expand Down Expand Up @@ -179,7 +179,7 @@ final class SerializationManager(

compiler.context.logSerializationManager(
debugLogLevel,
"Running serialization for bindings [{}].",
"Running serialization for bindings [{0}].",
libraryName
)
startSerializing(libraryName.toQualifiedName)
Expand Down Expand Up @@ -312,14 +312,14 @@ final class SerializationManager(
case result @ Some(_: SuggestionsCache.CachedSuggestions) =>
compiler.context.logSerializationManager(
Level.FINE,
"Restored suggestions for library [{}].",
"Restored suggestions for library [{0}].",
libraryName
)
result
case _ =>
compiler.context.logSerializationManager(
Level.FINEST,
"Unable to load suggestions for library [{}].",
"Unable to load suggestions for library [{0}].",
libraryName
)
None
Expand All @@ -342,14 +342,14 @@ final class SerializationManager(
case result @ Some(_: ImportExportCache.CachedBindings) =>
compiler.context.logSerializationManager(
Level.FINE,
"Restored bindings for library [{}].",
"Restored bindings for library [{0}].",
libraryName
)
result
case _ =>
compiler.context.logSerializationManager(
Level.FINEST,
"Unable to load bindings for library [{}].",
"Unable to load bindings for library [{0}].",
libraryName
)
None
Expand Down Expand Up @@ -396,7 +396,7 @@ final class SerializationManager(
)
compiler.context.logSerializationManager(
debugLogLevel,
"Restored IR from cache for module [{}] at stage [{}].",
"Restored IR from cache for module [{0}] at stage [{1}].",
module.getName,
loadedCache.compilationStage()
)
Expand All @@ -405,14 +405,14 @@ final class SerializationManager(
compiler.context.updateModule(module, _.hasCrossModuleLinks(true))
compiler.context.logSerializationManager(
debugLogLevel,
"Restored links (early phase) in module [{}].",
"Restored links (early phase) in module [{0}].",
module.getName
)
Some(true)
} else {
compiler.context.logSerializationManager(
debugLogLevel,
"Could not restore links (early phase) in module [{}].",
"Could not restore links (early phase) in module [{0}].",
module.getName
)
compiler.context.updateModule(module, _.hasCrossModuleLinks(false))
Expand All @@ -421,7 +421,7 @@ final class SerializationManager(
case None =>
compiler.context.logSerializationManager(
debugLogLevel,
"Unable to load a cache for module [{}].",
"Unable to load a cache for module [{0}].",
module.getName
)
None
Expand Down Expand Up @@ -518,7 +518,7 @@ final class SerializationManager(
val jobCount = waitingCount + isSerializing.size
compiler.context.logSerializationManager(
debugLogLevel,
"Waiting for #{} serialization jobs to complete.",
"Waiting for #{0} serialization jobs to complete.",
jobCount
)

Expand Down Expand Up @@ -585,7 +585,7 @@ final class SerializationManager(

compiler.context.logSerializationManager(
debugLogLevel,
"Running serialization for module [{}].",
"Running serialization for module [{0}].",
name
)
startSerializing(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ public void initContext() {
RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
Paths.get("../../distribution/component").toFile().getAbsolutePath()
)
.logHandler(OutputStream.nullOutputStream())
.option(
RuntimeOptions.LOG_LEVEL,
"FINEST"
)
.logHandler(System.out)//OutputStream.nullOutputStream())
.build();

context = Context.newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,15 @@ private ILoggingEvent toEvent(LogRecord record) {
LoggingEvent event = new LoggingEvent();
event.setLoggerName(record.getLoggerName());
event.setLevel(toLogbackLevel(record.getLevel()));
event.setMessage(record.getMessage());
event.setArgumentArray(record.getParameters());
// Replace jul-specific placeholders with ones used by everybody else
event.setMessage(record.getMessage().replaceAll("\\{\\d+\\}", "{}"));
Object[] args;
if (record.getParameters().length == 1 && record.getParameters()[0] instanceof Object[]) {
args = (Object[]) (record.getParameters()[0]);
} else {
args = record.getParameters();
}
event.setArgumentArray(args);
event.setInstant(record.getInstant());
if (record.getThrown() != null) {
event.setThrowableProxy(new ThrowableProxy(record.getThrown()));
Expand Down

0 comments on commit d844b56

Please sign in to comment.