From 47c136ccc1f20285fcdfeea94be886d5118f532c Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Fri, 25 Oct 2024 13:41:59 +0200 Subject: [PATCH] wasm gc: fix support for java.util.logging Fix #964 --- .../classlib/java/util/logging/TLogger.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/logging/TLogger.java b/classlib/src/main/java/org/teavm/classlib/java/util/logging/TLogger.java index a42bd835d..88f705913 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/logging/TLogger.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/logging/TLogger.java @@ -23,6 +23,7 @@ import org.teavm.classlib.java.lang.TThrowable; import org.teavm.classlib.java.util.THashMap; import org.teavm.classlib.java.util.TMap; import org.teavm.jso.JSBody; +import org.teavm.jso.impl.JS; public class TLogger { public static final String GLOBAL_LOGGER_NAME = "global"; @@ -70,11 +71,23 @@ public class TLogger { } } else { if (record.getLevel().intValue() >= TLevel.SEVERE.intValue()) { - error(message); + if (PlatformDetector.isWebAssemblyGC()) { + JS.invoke(JS.global("console"), JS.wrap("error"), JS.wrap(message)); + } else { + error(message); + } } else if (record.getLevel().intValue() >= TLevel.WARNING.intValue()) { - warn(message); + if (PlatformDetector.isWebAssemblyGC()) { + JS.invoke(JS.global("console"), JS.wrap("warn"), JS.wrap(message)); + } else { + warn(message); + } } else { - infoImpl(message); + if (PlatformDetector.isWebAssemblyGC()) { + JS.invoke(JS.global("console"), JS.wrap("info"), JS.wrap(message)); + } else { + infoImpl(message); + } } } }