Compare commits
No commits in common. "468e206fab8993e221045158c05002178ff911d7" and "78b12dee67950eaa50469b67058096cb9d2f4fa3" have entirely different histories.
468e206fab
...
78b12dee67
8 changed files with 35 additions and 323 deletions
|
@ -92,7 +92,7 @@ public final class Engine extends SubsystemClass {
|
||||||
* @see LoggerInstance
|
* @see LoggerInstance
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*/
|
*/
|
||||||
private static final LoggerInstance logger = new LoggerInstance.Builder().setClazz(Engine.class).setOrigin("ENGINE").setMetadata(EngineInformation.getVersioningCodename()).build();
|
private static LoggerInstance logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains the engine state.
|
* Contains the engine state.
|
||||||
|
@ -162,18 +162,19 @@ public final class Engine extends SubsystemClass {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
long initTime = Miscellaneous.measureExecutionTime(() -> {
|
long initTime = Miscellaneous.measureExecutionTime(() -> {
|
||||||
state = EngineState.EARLY_STARTUP;
|
state = EngineState.STARTUP;
|
||||||
|
|
||||||
|
// Initialize engine configuration
|
||||||
new EngineConfiguration();
|
new EngineConfiguration();
|
||||||
EngineConfiguration.getInstance().loadConfiguration();
|
EngineConfiguration.getInstance().loadConfiguration();
|
||||||
|
|
||||||
logger.info("Initializing engine");
|
|
||||||
initializeClasses(); // Initialize classes
|
initializeClasses(); // Initialize classes
|
||||||
populateCrashContent(); // Populate crash content
|
populateCrashContent(); // Populate crash content
|
||||||
cacheEvents(); // Cache event listeners
|
cacheEvents(); // Cache event listeners
|
||||||
startThreads(); // Start threads
|
startThreads(); // Start threads
|
||||||
|
|
||||||
state = EngineState.STARTUP;
|
// Set the logger instance
|
||||||
|
logger = new LoggerInstance.Builder().setClazz(getClass()).setOrigin("ENGINE").setMetadata(EngineInformation.getVersioningCodename()).build();
|
||||||
|
|
||||||
// Perform automatic subsystem initialization
|
// Perform automatic subsystem initialization
|
||||||
if (EngineConfiguration.getInstance().isOptimizeSubsystemInitialization()) {
|
if (EngineConfiguration.getInstance().isOptimizeSubsystemInitialization()) {
|
||||||
|
@ -198,10 +199,9 @@ public final class Engine extends SubsystemClass {
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*/
|
*/
|
||||||
private void initializeClasses() {
|
private void initializeClasses() {
|
||||||
logger.verb("Initializing engine classes");
|
|
||||||
new PlaceholderEngine();
|
new PlaceholderEngine();
|
||||||
|
|
||||||
EngineInformation.update();
|
EngineInformation.updateVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -212,8 +212,6 @@ public final class Engine extends SubsystemClass {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "ExtractMethodRecommender" })
|
@SuppressWarnings({ "ExtractMethodRecommender" })
|
||||||
private void populateCrashContent() {
|
private void populateCrashContent() {
|
||||||
logger.diag("Populating crash content");
|
|
||||||
|
|
||||||
// Issuer
|
// Issuer
|
||||||
Map<@NotNull String, @NotNull String> crashContentIssuer = new LinkedHashMap<>();
|
Map<@NotNull String, @NotNull String> crashContentIssuer = new LinkedHashMap<>();
|
||||||
crashContentIssuer.put("Code part", "%issuer_origin%");
|
crashContentIssuer.put("Code part", "%issuer_origin%");
|
||||||
|
@ -263,8 +261,6 @@ public final class Engine extends SubsystemClass {
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*/
|
*/
|
||||||
private void cacheEvents() {
|
private void cacheEvents() {
|
||||||
logger.diag("Caching events");
|
|
||||||
|
|
||||||
// Internal events
|
// Internal events
|
||||||
EventHelper.cacheEvent(InternalEngineShutdownEvent.class);
|
EventHelper.cacheEvent(InternalEngineShutdownEvent.class);
|
||||||
|
|
||||||
|
@ -282,8 +278,6 @@ public final class Engine extends SubsystemClass {
|
||||||
* @since v1-alpha1
|
* @since v1-alpha1
|
||||||
*/
|
*/
|
||||||
public void startThreads() {
|
public void startThreads() {
|
||||||
logger.diag("Starting threads");
|
|
||||||
|
|
||||||
Logger.startLoggingThread();
|
Logger.startLoggingThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -314,20 +314,19 @@ public final class EngineInformation {
|
||||||
/**
|
/**
|
||||||
* Updates all variables.
|
* Updates all variables.
|
||||||
* <p>
|
* <p>
|
||||||
* This method does not need to be invoked manually, as the information provided by
|
* This method does not need to be invoked, as the information provided by this
|
||||||
* this class is static (does not change) and is already populated at engine startup.
|
* class is static (does not change) and is already populated at engine startup.
|
||||||
*
|
*
|
||||||
* @since v1-alpha1
|
* @since v1-alpha1
|
||||||
*/
|
*/
|
||||||
public static synchronized void update() {
|
public static synchronized void updateVariables() {
|
||||||
logger.diag("Updating engine information");
|
|
||||||
|
|
||||||
// Load properties from bundled gradle.properties
|
// Load properties from bundled gradle.properties
|
||||||
Properties gradleProperties = new Properties();
|
Properties gradleProperties = new Properties();
|
||||||
InputStream gradleStream = EngineInformation.class.getClassLoader().getResourceAsStream("sosengine-gradle.properties");
|
InputStream gradleStream = EngineInformation.class.getClassLoader().getResourceAsStream("sosengine-gradle.properties");
|
||||||
|
|
||||||
if (gradleStream == null) {
|
if (gradleStream == null) {
|
||||||
logger.crash("Unable to load build information: The bundled gradle.properties file could not be found.");
|
System.out.println("Unable to load build information: The bundled gradle.properties file could not be found.");
|
||||||
|
Engine.getInstance().shutdown(69);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,7 +335,9 @@ public final class EngineInformation {
|
||||||
gradleStream.close();
|
gradleStream.close();
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
StackTraceParser parser = new StackTraceParser(exception);
|
StackTraceParser parser = new StackTraceParser(exception);
|
||||||
logger.crash("Unable to load build information: InputStream 'gradleStream' failed", exception);
|
System.out.println("Unable to load build information: InputStream 'gradleStream' failed");
|
||||||
|
System.out.println(parser.getHeader() + "\n" + parser.getStackTrace());
|
||||||
|
Engine.getInstance().shutdown(69);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,7 +365,9 @@ public final class EngineInformation {
|
||||||
gitStream.close();
|
gitStream.close();
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
StackTraceParser parser = new StackTraceParser(exception);
|
StackTraceParser parser = new StackTraceParser(exception);
|
||||||
logger.crash("Unable to load build information: InputStream 'gitStream' failed", exception);
|
System.out.println("Unable to load build information: InputStream 'gitStream' failed");
|
||||||
|
System.out.println(parser.getHeader() + "\n" + parser.getStackTrace());
|
||||||
|
Engine.getInstance().shutdown(69);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,201 +0,0 @@
|
||||||
/*
|
|
||||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
|
||||||
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
|
||||||
* Licensed under the GNU Affero General Public License v3
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.staropensource.sosengine.base.logging;
|
|
||||||
|
|
||||||
import de.staropensource.sosengine.base.EngineConfiguration;
|
|
||||||
import de.staropensource.sosengine.base.internal.placeholders.logger.LogMessage;
|
|
||||||
import de.staropensource.sosengine.base.internal.placeholders.logger.LogPath;
|
|
||||||
import de.staropensource.sosengine.base.types.logging.LogLevel;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides logging capabilities during engine startup.
|
|
||||||
*
|
|
||||||
* @since v1-alpha4
|
|
||||||
*/
|
|
||||||
public final class InitLogger {
|
|
||||||
/**
|
|
||||||
* Contains the logging template used during startup.
|
|
||||||
*
|
|
||||||
* @since v1-alpha4
|
|
||||||
*/
|
|
||||||
private static final @NotNull String template = "%log_level% %log_path% %log_message%";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs this class.
|
|
||||||
*
|
|
||||||
* @since v1-alpha4
|
|
||||||
*/
|
|
||||||
public InitLogger() {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link Logger#log(LogLevel, Class, String, String, String)} and {@link Logger#processLogMessage(LogLevel, Class, String, String, String)} combined into one method.
|
|
||||||
*
|
|
||||||
* @param level level
|
|
||||||
* @param issuerClass class of the issuer
|
|
||||||
* @param issuerOrigin origin of the issuer
|
|
||||||
* @param issuerMetadata metadata about the issuer
|
|
||||||
* @param message message
|
|
||||||
* @since v1-alpha4
|
|
||||||
*/
|
|
||||||
private static synchronized void log(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message) {
|
|
||||||
// Dismiss if level is not allowed
|
|
||||||
if (level.compareTo(EngineConfiguration.getInstance().getLoggerLevel()) < 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Invoke LoggerImpl#prePlaceholder
|
|
||||||
String base = Logger.getLoggerImplementation().prePlaceholder(level, issuerClass, issuerOrigin, issuerMetadata, message, template);
|
|
||||||
if (base == null)
|
|
||||||
base = template;
|
|
||||||
|
|
||||||
// Replace placeholders
|
|
||||||
// This is done manually to avoid depending on PlaceholderEngine
|
|
||||||
base = new de.staropensource.sosengine.base.internal.placeholders.logger.LogLevel(level).replace(base);
|
|
||||||
base = new LogPath(issuerClass).replace(base);
|
|
||||||
base = new LogMessage(message).replace(base);
|
|
||||||
|
|
||||||
// Invoke LoggerImpl#postPlaceholder
|
|
||||||
base = Logger.getLoggerImplementation().postPlaceholder(level, issuerClass, issuerOrigin, issuerMetadata, message, base);
|
|
||||||
|
|
||||||
// Print log message by invoking LoggerImpl#print
|
|
||||||
Logger.getLoggerImplementation().print(level, issuerClass, issuerOrigin, issuerMetadata, message, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prints a diagnostic message.
|
|
||||||
*
|
|
||||||
* @param issuerClass class of the issuer
|
|
||||||
* @param issuerOrigin origin of the issuer
|
|
||||||
* @param issuerMetadata metadata about the issuer
|
|
||||||
* @param message message
|
|
||||||
* @since v1-alpha4
|
|
||||||
*/
|
|
||||||
public static void diag(@NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message) {
|
|
||||||
log(LogLevel.DIAGNOSTIC, issuerClass, issuerOrigin, issuerMetadata, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prints a verbose message.
|
|
||||||
*
|
|
||||||
* @param issuerClass class of the issuer
|
|
||||||
* @param issuerOrigin origin of the issuer
|
|
||||||
* @param issuerMetadata metadata about the issuer
|
|
||||||
* @param message message
|
|
||||||
* @since v1-alpha4
|
|
||||||
*/
|
|
||||||
public static void verb(@NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message) {
|
|
||||||
log(LogLevel.VERBOSE, issuerClass, issuerOrigin, issuerMetadata, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prints a silent warning message.
|
|
||||||
*
|
|
||||||
* @param issuerClass class of the issuer
|
|
||||||
* @param issuerOrigin origin of the issuer
|
|
||||||
* @param issuerMetadata metadata about the issuer
|
|
||||||
* @param message message
|
|
||||||
* @since v1-alpha4
|
|
||||||
*/
|
|
||||||
public static void sarn(@NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message) {
|
|
||||||
log(LogLevel.SILENT_WARNING, issuerClass, issuerOrigin, issuerMetadata, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prints an informational message.
|
|
||||||
*
|
|
||||||
* @param issuerClass class of the issuer
|
|
||||||
* @param issuerOrigin origin of the issuer
|
|
||||||
* @param issuerMetadata metadata about the issuer
|
|
||||||
* @param message message
|
|
||||||
* @since v1-alpha4
|
|
||||||
*/
|
|
||||||
public static void info(@NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message) {
|
|
||||||
log(LogLevel.INFORMATIONAL, issuerClass, issuerOrigin, issuerMetadata, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prints a warning message.
|
|
||||||
*
|
|
||||||
* @param issuerClass class of the issuer
|
|
||||||
* @param issuerOrigin origin of the issuer
|
|
||||||
* @param issuerMetadata metadata about the issuer
|
|
||||||
* @param message message
|
|
||||||
* @since v1-alpha4
|
|
||||||
*/
|
|
||||||
public static void warn(@NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message) {
|
|
||||||
log(LogLevel.WARNING, issuerClass, issuerOrigin, issuerMetadata, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prints an error message.
|
|
||||||
*
|
|
||||||
* @param issuerClass class of the issuer
|
|
||||||
* @param issuerOrigin origin of the issuer
|
|
||||||
* @param issuerMetadata metadata about the issuer
|
|
||||||
* @param message message
|
|
||||||
* @since v1-alpha4
|
|
||||||
*/
|
|
||||||
public static void error(@NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message) {
|
|
||||||
log(LogLevel.ERROR, issuerClass, issuerOrigin, issuerMetadata, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Crashes the entire engine.
|
|
||||||
*
|
|
||||||
* @param issuerClass class of the issuer
|
|
||||||
* @param issuerOrigin origin of the issuer
|
|
||||||
* @param issuerMetadata metadata about the issuer
|
|
||||||
* @param message message
|
|
||||||
* @param throwable the throwable that caused this crash
|
|
||||||
* @param handled declares the throwable has handled, not causing the engine to shutdown
|
|
||||||
* @since v1-alpha4
|
|
||||||
*/
|
|
||||||
public static void crash(@NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull Throwable throwable, boolean handled) {
|
|
||||||
Logger.crash(issuerClass, issuerOrigin, issuerMetadata, message, throwable, handled);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Crashes the entire engine.
|
|
||||||
*
|
|
||||||
* @param issuerClass class of the issuer
|
|
||||||
* @param issuerOrigin origin of the issuer
|
|
||||||
* @param issuerMetadata metadata about the issuer
|
|
||||||
* @param message message
|
|
||||||
* @param throwable the throwable that caused this crash
|
|
||||||
* @since v1-alpha4
|
|
||||||
*/
|
|
||||||
public static void crash(@NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull Throwable throwable) {
|
|
||||||
Logger.crash(issuerClass, issuerOrigin, issuerMetadata, message, throwable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Crashes the entire engine.
|
|
||||||
*
|
|
||||||
* @param issuerClass class of the issuer
|
|
||||||
* @param issuerOrigin origin of the issuer
|
|
||||||
* @param issuerMetadata metadata about the issuer
|
|
||||||
* @param message message
|
|
||||||
* @since v1-alpha4
|
|
||||||
*/
|
|
||||||
public static void crash(@NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message) {
|
|
||||||
Logger.crash(issuerClass, issuerOrigin, issuerMetadata, message);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -19,8 +19,6 @@
|
||||||
|
|
||||||
package de.staropensource.sosengine.base.logging;
|
package de.staropensource.sosengine.base.logging;
|
||||||
|
|
||||||
import de.staropensource.sosengine.base.Engine;
|
|
||||||
import de.staropensource.sosengine.base.types.EngineState;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
@ -90,10 +88,7 @@ public final class LoggerInstance {
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*/
|
*/
|
||||||
public void diag(@NotNull String message) {
|
public void diag(@NotNull String message) {
|
||||||
if (Engine.getInstance().getState() == EngineState.EARLY_STARTUP)
|
Logger.diag(clazz, origin, metadata, message);
|
||||||
InitLogger.diag(clazz, origin, metadata, message);
|
|
||||||
else
|
|
||||||
Logger.diag(clazz, origin, metadata, message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,10 +98,7 @@ public final class LoggerInstance {
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*/
|
*/
|
||||||
public void verb(@NotNull String message) {
|
public void verb(@NotNull String message) {
|
||||||
if (Engine.getInstance().getState() == EngineState.EARLY_STARTUP)
|
Logger.verb(clazz, origin, metadata, message);
|
||||||
InitLogger.verb(clazz, origin, metadata, message);
|
|
||||||
else
|
|
||||||
Logger.verb(clazz, origin, metadata, message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,10 +108,7 @@ public final class LoggerInstance {
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*/
|
*/
|
||||||
public void sarn(@NotNull String message) {
|
public void sarn(@NotNull String message) {
|
||||||
if (Engine.getInstance().getState() == EngineState.EARLY_STARTUP)
|
Logger.sarn(clazz, origin, metadata, message);
|
||||||
InitLogger.sarn(clazz, origin, metadata, message);
|
|
||||||
else
|
|
||||||
Logger.sarn(clazz, origin, metadata, message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -129,10 +118,7 @@ public final class LoggerInstance {
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*/
|
*/
|
||||||
public void info(@NotNull String message) {
|
public void info(@NotNull String message) {
|
||||||
if (Engine.getInstance().getState() == EngineState.EARLY_STARTUP)
|
Logger.info(clazz, origin, metadata, message);
|
||||||
InitLogger.info(clazz, origin, metadata, message);
|
|
||||||
else
|
|
||||||
Logger.info(clazz, origin, metadata, message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -142,10 +128,7 @@ public final class LoggerInstance {
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*/
|
*/
|
||||||
public void warn(@NotNull String message) {
|
public void warn(@NotNull String message) {
|
||||||
if (Engine.getInstance().getState() == EngineState.EARLY_STARTUP)
|
Logger.warn(clazz, origin, metadata, message);
|
||||||
InitLogger.warn(clazz, origin, metadata, message);
|
|
||||||
else
|
|
||||||
Logger.warn(clazz, origin, metadata, message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,10 +138,7 @@ public final class LoggerInstance {
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*/
|
*/
|
||||||
public void error(@NotNull String message) {
|
public void error(@NotNull String message) {
|
||||||
if (Engine.getInstance().getState() == EngineState.EARLY_STARTUP)
|
Logger.error(clazz, origin, metadata, message);
|
||||||
InitLogger.error(clazz, origin, metadata, message);
|
|
||||||
else
|
|
||||||
Logger.error(clazz, origin, metadata, message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -45,14 +45,16 @@ public class PlainLoggerImplementation implements LoggerImplementation {
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public @Nullable String prePlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
|
public @NotNull String prePlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
|
||||||
return null; // No modifications necessary
|
// No modifications necessary
|
||||||
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String postPlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
|
public @NotNull String postPlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
|
||||||
return format; // No modifications necessary
|
// No modifications necessary
|
||||||
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
/*
|
|
||||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
|
||||||
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
|
||||||
* Licensed under the GNU Affero General Public License v3
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.staropensource.sosengine.base.logging.implementation;
|
|
||||||
|
|
||||||
import de.staropensource.sosengine.base.classes.LoggerImplementation;
|
|
||||||
import de.staropensource.sosengine.base.types.logging.LogLevel;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An implementation of {@link LoggerImplementation}, which does nothing.
|
|
||||||
* Useful if you want to silence engine startup messages.
|
|
||||||
*
|
|
||||||
* @since v1-alpha4
|
|
||||||
*/
|
|
||||||
public class QuietLoggerImplementation implements LoggerImplementation {
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public @Nullable String prePlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public @NotNull String postPlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
|
|
||||||
return format;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public void print(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {}
|
|
||||||
}
|
|
|
@ -45,14 +45,16 @@ public class RawLoggerImplementation implements LoggerImplementation {
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public @Nullable String prePlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
|
public @NotNull String prePlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
|
||||||
return null; // No modifications necessary
|
// No modifications necessary
|
||||||
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String postPlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
|
public @NotNull String postPlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
|
||||||
return format; // No modifications necessary
|
// No modifications necessary
|
||||||
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
|
|
@ -19,9 +19,6 @@
|
||||||
|
|
||||||
package de.staropensource.sosengine.base.types;
|
package de.staropensource.sosengine.base.types;
|
||||||
|
|
||||||
import de.staropensource.sosengine.base.logging.InitLogger;
|
|
||||||
import de.staropensource.sosengine.base.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines in which state the engine is currently in.
|
* Determines in which state the engine is currently in.
|
||||||
*
|
*
|
||||||
|
@ -38,25 +35,9 @@ public enum EngineState {
|
||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The engine is in early startup.
|
* The engine is currently starting up.
|
||||||
* The engine is largely uninitialized and
|
|
||||||
* the logging infrastructure is not yet ready
|
|
||||||
* to be used.
|
|
||||||
* <p>
|
|
||||||
* This state is used to indicate that the
|
|
||||||
* {@link InitLogger} shall be used instead
|
|
||||||
* of {@link Logger}.
|
|
||||||
*
|
|
||||||
* @since v1-alpha4
|
|
||||||
*/
|
|
||||||
EARLY_STARTUP,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The engine is starting up.
|
|
||||||
* Some parts of the engine may not be initialized
|
* Some parts of the engine may not be initialized
|
||||||
* yet and may be unsafe to access. The logging
|
* yet and may be unsafe to access.
|
||||||
* infrastructure is ready to be used though and is
|
|
||||||
* safe to access.
|
|
||||||
*
|
*
|
||||||
* @since v1-alpha2
|
* @since v1-alpha2
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue