diff --git a/plugin_ide.core/src-lang/melnorme/lang/ide/core/AbstractLangCore.java b/plugin_ide.core/src-lang/melnorme/lang/ide/core/AbstractLangCore.java index 27c33701e..284b730bd 100644 --- a/plugin_ide.core/src-lang/melnorme/lang/ide/core/AbstractLangCore.java +++ b/plugin_ide.core/src-lang/melnorme/lang/ide/core/AbstractLangCore.java @@ -16,8 +16,9 @@ import melnorme.lang.ide.core.project_model.BundleModelManager; import melnorme.lang.ide.core.project_model.LangBundleModel; import melnorme.utilbox.misc.ILogHandler; +import melnorme.utilbox.status.StatusException; -public abstract class AbstractLangCore { +public abstract class AbstractLangCore extends LoggingCore { public static LangCore instance; @@ -54,7 +55,7 @@ protected void shutdown() { /* ----------------- ----------------- */ - public static ILogHandler logHandler() { + public static ILogHandler log() { return instance.logHandler; } @@ -94,4 +95,44 @@ public void startAgentsAfterUIStart() { bundleManager.startManager(); } +} + +class LoggingCore { + + public static ILogHandler log() { + return AbstractLangCore.instance.logHandler; + } + + /** Logs status of given StatusException. */ + public static void logStatusException(StatusException se) { + log().logStatus(se); + } + + /** Logs an error status with given message. */ + public static void logError(String message) { + log().logError(message); + } + /** Logs an error status with given message and given throwable. */ + public static void logError(String message, Throwable throwable) { + log().logError(message, throwable); + } + + /** Logs a warning status with given message. */ + public static void logWarning(String message) { + log().logWarning(message); + } + /** Logs a warning status with given message and given throwable. */ + public static void logWarning(String message, Throwable throwable) { + log().logWarning(message, throwable); + } + + /** Logs an info status with given message. */ + public static void logInfo(String message) { + log().logInfo(message); + } + + public static void logInternalError(Throwable throwable) { + log().logError("Internal Error!", throwable); + } + } \ No newline at end of file diff --git a/plugin_ide.core/src-lang/melnorme/lang/ide/core/LangCore.java b/plugin_ide.core/src-lang/melnorme/lang/ide/core/LangCore.java index 1c8037ff0..05da267b8 100644 --- a/plugin_ide.core/src-lang/melnorme/lang/ide/core/LangCore.java +++ b/plugin_ide.core/src-lang/melnorme/lang/ide/core/LangCore.java @@ -11,8 +11,6 @@ package melnorme.lang.ide.core; import melnorme.utilbox.misc.ILogHandler; -import melnorme.utilbox.status.Severity; -import melnorme.utilbox.status.StatusException; public class LangCore extends LangCore_Actual { @@ -20,38 +18,4 @@ public LangCore(ILogHandler logHandler) { super(logHandler); } - /* ----------------- Logging ----------------- */ - - /** Logs status of given StatusException. */ - public static void logStatusException(StatusException se) { - logHandler().logStatus(se); - } - - public static void logInternalError(Throwable throwable) { - logError("Internal Error!", throwable); - } - - /** Logs an error status with given message. */ - public static void logError(String message) { - logError(message, null); - } - /** Logs an error status with given message and given throwable. */ - public static void logError(String message, Throwable throwable) { - logStatusException(new StatusException(Severity.ERROR, message, throwable)); - } - - /** Logs a warning status with given message. */ - public static void logWarning(String message) { - logWarning(message, null); - } - /** Logs a warning status with given message and given throwable. */ - public static void logWarning(String message, Throwable throwable) { - logStatusException(new StatusException(Severity.WARNING, message, throwable)); - } - - /** Logs an info status with given message. */ - public static void logInfo(String message) { - logStatusException(new StatusException(Severity.INFO, message, null)); - } - } \ No newline at end of file diff --git a/plugin_ide.core/src-lang/melnorme/lang/ide/core/utils/process/AbstractRunProcessTask.java b/plugin_ide.core/src-lang/melnorme/lang/ide/core/utils/process/AbstractRunProcessTask.java index 81b7b1eea..25544e90f 100644 --- a/plugin_ide.core/src-lang/melnorme/lang/ide/core/utils/process/AbstractRunProcessTask.java +++ b/plugin_ide.core/src-lang/melnorme/lang/ide/core/utils/process/AbstractRunProcessTask.java @@ -67,7 +67,7 @@ public void addProcessListener(IProcessOutputListener listener) throws CommonExc }); try { - return new ExternalProcessNotifyingHelper(process, true, pm, processListeners, LangCore.logHandler()); + return new ExternalProcessNotifyingHelper(process, true, pm, processListeners, LangCore.log()); } finally { processListeners = null; // Set to null to fail fast if anyone else tries to modify afterward. } diff --git a/plugin_tooling/src-util/melnorme/utilbox/misc/ILogHandler.java b/plugin_tooling/src-util/melnorme/utilbox/misc/ILogHandler.java index 1243c1649..8944c15ec 100644 --- a/plugin_tooling/src-util/melnorme/utilbox/misc/ILogHandler.java +++ b/plugin_tooling/src-util/melnorme/utilbox/misc/ILogHandler.java @@ -10,6 +10,7 @@ *******************************************************************************/ package melnorme.utilbox.misc; +import melnorme.utilbox.status.Severity; import melnorme.utilbox.status.StatusException; @@ -17,4 +18,27 @@ public interface ILogHandler { void logStatus(StatusException statusException); + /** Logs an error status with given message. */ + default void logError(String message) { + logError(message, null); + } + /** Logs an error status with given message and given throwable. */ + default void logError(String message, Throwable throwable) { + logStatus(new StatusException(Severity.ERROR, message, throwable)); + } + + /** Logs a warning status with given message. */ + default void logWarning(String message) { + logWarning(message, null); + } + /** Logs a warning status with given message and given throwable. */ + default void logWarning(String message, Throwable throwable) { + logStatus(new StatusException(Severity.WARNING, message, throwable)); + } + + /** Logs an info status with given message. */ + default void logInfo(String message) { + logStatus(new StatusException(Severity.INFO, message, null)); + } + } \ No newline at end of file