forked from StarOpenSource/Engine
Add 'level' and 'origin' log features
This commit is contained in:
parent
571d600b09
commit
ed1c1d3b1a
2 changed files with 31 additions and 24 deletions
|
@ -309,6 +309,8 @@ public final class EngineConfiguration extends Configuration {
|
||||||
* <li><code>moduleVersion</code> (requires <code>moduleName</code>)</li>
|
* <li><code>moduleVersion</code> (requires <code>moduleName</code>)</li>
|
||||||
* <li><code>methodName</code></li>
|
* <li><code>methodName</code></li>
|
||||||
* <li><code>lineNumber</code></li>
|
* <li><code>lineNumber</code></li>
|
||||||
|
* <li><code>level</code></li>
|
||||||
|
* <li><code>origin</code></li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @return optional features to enable
|
* @return optional features to enable
|
||||||
|
@ -490,7 +492,7 @@ public final class EngineConfiguration extends Configuration {
|
||||||
optimizeEvents = true;
|
optimizeEvents = true;
|
||||||
|
|
||||||
logLevel = LogLevel.INFORMATIONAL;
|
logLevel = LogLevel.INFORMATIONAL;
|
||||||
logFeatures = Set.of("formatting", "time", "methodName", "lineNumber");
|
logFeatures = Set.of("formatting", "time", "methodName", "lineNumber", "level", "origin");
|
||||||
logPollingSpeed = 5;
|
logPollingSpeed = 5;
|
||||||
logForceStandardOutput = false;
|
logForceStandardOutput = false;
|
||||||
|
|
||||||
|
|
|
@ -113,20 +113,25 @@ public final class Processor {
|
||||||
if (isFeatureEnabled("date") || isFeatureEnabled("time")) {
|
if (isFeatureEnabled("date") || isFeatureEnabled("time")) {
|
||||||
output.append("[");
|
output.append("[");
|
||||||
date(output);
|
date(output);
|
||||||
if (isFeatureEnabled("date"))
|
if (isFeatureEnabled("date") && isFeatureEnabled("time"))
|
||||||
output.append(" ");
|
output.append(" ");
|
||||||
time(output);
|
time(output);
|
||||||
output.append("] ");
|
output.append("] ");
|
||||||
}
|
}
|
||||||
output.append("[");
|
|
||||||
level(output, level);
|
if (isFeatureEnabled("level") || isFeatureEnabled("origin")) {
|
||||||
format(output, level);
|
output.append("[");
|
||||||
output.append(" ");
|
level(output, level);
|
||||||
issuerClass(output, level, issuer);
|
if (isFeatureEnabled("level") && isFeatureEnabled("origin"))
|
||||||
issuerModule(output, level, issuer);
|
output.append(" ");
|
||||||
methodName(output, level, issuer);
|
if (isFeatureEnabled("origin")) {
|
||||||
lineNumber(output, level, issuer);
|
issuerClass(output, level, issuer);
|
||||||
output.append("] ");
|
issuerModule(output, level, issuer);
|
||||||
|
methodName(output, level, issuer);
|
||||||
|
lineNumber(output, level, issuer);
|
||||||
|
}
|
||||||
|
output.append("] ");
|
||||||
|
}
|
||||||
message(output, message);
|
message(output, message);
|
||||||
format(output, "reset");
|
format(output, "reset");
|
||||||
|
|
||||||
|
@ -244,19 +249,21 @@ public final class Processor {
|
||||||
* @since v1-alpha8
|
* @since v1-alpha8
|
||||||
*/
|
*/
|
||||||
private static void level(@NotNull StringBuilder builder, @NotNull LogLevel level) {
|
private static void level(@NotNull StringBuilder builder, @NotNull LogLevel level) {
|
||||||
format(builder, "bold");
|
if (isFeatureEnabled("level")) {
|
||||||
|
format(builder, "bold");
|
||||||
|
|
||||||
builder.append(switch (level) {
|
builder.append(switch (level) {
|
||||||
case DIAGNOSTIC -> "DIAG";
|
case DIAGNOSTIC -> "DIAG";
|
||||||
case VERBOSE -> "VERB";
|
case VERBOSE -> "VERB";
|
||||||
case SILENT_WARNING -> "SARN";
|
case SILENT_WARNING -> "SARN";
|
||||||
case INFORMATIONAL -> "INFO";
|
case INFORMATIONAL -> "INFO";
|
||||||
case WARNING -> "WARN";
|
case WARNING -> "WARN";
|
||||||
case ERROR -> "ERR!";
|
case ERROR -> "ERR!";
|
||||||
case CRASH -> "CRSH";
|
case CRASH -> "CRSH";
|
||||||
});
|
});
|
||||||
|
|
||||||
format(builder, level);
|
format(builder, level);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -275,8 +282,6 @@ public final class Processor {
|
||||||
builder.append(classNameSplit[classNameSplit.length - 1]);
|
builder.append(classNameSplit[classNameSplit.length - 1]);
|
||||||
} else
|
} else
|
||||||
builder.append(issuer.getClassName());
|
builder.append(issuer.getClassName());
|
||||||
|
|
||||||
format(builder, level);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue