Closed juherr closed 2 weeks ago
We can't use the new logging without dropping support for older Jetbrains IDE versions. For now, ignoring the logging exception with f9b81eabd6491524ea3ec45ca7ba7c2e56114d05, released in v14.3.14.
The long term solution is creating a new legacy plugin repo and marketplace listing for older IDEs, then upgrading the SDK used by this plugin to support the newer IDEs.
I still get this exception reported even with 14.3.14:
java.lang.Throwable: Do not use, call '#setLevel(LogLevel)' instead
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:376)
at com.intellij.openapi.diagnostic.Logger.setLevel(Logger.java:484)
at com.wakatime.intellij.plugin.WakaTime.setLoggingLevel(WakaTime.java:586)
at com.wakatime.intellij.plugin.WakaTime.initComponent(WakaTime.java:96)
Fixed with 821a9d8d5dd359e71980272fb80b79fe32cc8222.
Your fix looks fine, but I am sorry to report the issue persists:
java.lang.Throwable: Do not use, call '#setLevel(LogLevel)' instead at com.intellij.openapi.diagnostic.Logger.error(Logger.java:376) at com.intellij.openapi.diagnostic.Logger.setLevel(Logger.java:484) at com.wakatime.intellij.plugin.WakaTime.setLoggingLevel(WakaTime.java:586) at com.wakatime.intellij.plugin.WakaTime.initComponent(WakaTime.java:96)
I do not know how exactly IDEA decides what to report as a crash report.
Are you sure you want to call System.out.println(e.getStackTrace());
on the catched exception? Or perhaps the exception stack is already dumped inside of log.setLevel
and it cannot be supressed this way?
It seems like #setLevel(Level) is deprecated as of this code from intellij openapi logger
/** @deprecated IntelliJ Platform no longer uses Log4j as the logging framework; please use {@link #setLevel(LogLevel)} instead */
@Deprecated
public void setLevel(@SuppressWarnings("unused") @NotNull Level level) {
error("Do not use, call '#setLevel(LogLevel)' instead");
}
public void setLevel(@NotNull LogLevel level) {
error(getClass() + " should override '#setLevel(LogLevel)'");
}
And LogLevel Enum contains the following code:
public enum LogLevel {
OFF(Level.OFF),
ERROR(Level.SEVERE),
WARNING(Level.WARNING),
INFO(Level.INFO),
DEBUG(Level.FINE),
TRACE(Level.FINER),
ALL(Level.ALL);
private final Level myLevel;
LogLevel(Level level) {
myLevel = level;
}
Level getLevel() {
return myLevel;
}
public String getLevelName() {
return myLevel.getName();
}
public @NotNull String getPrettyLevelName() {
return getPrettyLevelName(myLevel);
}
static @NotNull String getPrettyLevelName(@NotNull Level level) {
return level == Level.WARNING ? "WARN" : level.getName();
}
}
Using LogLevel
instead of Level
should theoretically fix it right...?
But Log4j2 uses Level
, no idea of how to fix this yet...
The SDK we currently target doesn't know about com.intellij.openapi.diagnostic
so we need to update the plugin SDK first.
On 2024.2 EAP platform:
From https://github.com/wakatime/jetbrains-wakatime/blob/master/src/com/wakatime/intellij/plugin/WakaTime.java#L581-L586