Skip to content

Commit

Permalink
Fix Logformat
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauriichan committed Apr 26, 2021
1 parent c296fa1 commit 1aba983
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.sourcewriters.minecraft</groupId>
<artifactId>vcompat</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
<name>vCompat</name>
<distributionManagement>
<repository>
Expand Down Expand Up @@ -245,7 +245,7 @@
</excludes>
</filter>
</filters>
<createDependencyReducedPom>false</createDependencyReducedPom>
<createDependencyReducedPom>true</createDependencyReducedPom>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,31 +236,31 @@ public BukkitLogger log(LogType type, String... messages) {
}

public BukkitLogger log(LogType type, String message) {
message = format.replace("%date%", Times.getDate(".").substring(0, 5)).replace("%time%", Times.getTime(":"))
String format = this.format.replace("%date%", Times.getDate(".").substring(0, 5)).replace("%time%", Times.getTime(":"))
.replace("%thread%", getThreadName()).replace("%plugin%", plugin);
try {
return colored ? sendColored(type, message) : sendUncolored(type, message);
return colored ? sendColored(type, format, message) : sendUncolored(type, format, message);
} catch (IOException e) {
e.printStackTrace();
}
return this;
}

private BukkitLogger sendColored(LogType type, String message) throws IOException {
private BukkitLogger sendColored(LogType type, String format, String message) throws IOException {
boolean colorMessage = this.colorMessage.contains(type.getId());
String ansi;
if (custom != null) {
boolean color = (ansi = type.asColorString(false)).length() != 0;
custom.accept(true,
message.replace("%type%", ansi).replace("%message%", (colorMessage ? ansi : "") + LoggingColors.format(message, color))
format.replace("%type%", ansi).replace("%message%", (colorMessage ? ansi : "") + LoggingColors.format(message, color))
+ (color ? ANSI_RESET : ""));
}
return sendStream(message.replace("%type%", ansi = type.asColorString(true)).replace("%message%",
return sendStream(format.replace("%type%", ansi = type.asColorString(true)).replace("%message%",
(colorMessage ? ansi : "") + LoggingColors.format(message, true)) + ANSI_RESET);
}

private BukkitLogger sendUncolored(LogType type, String message) throws IOException {
message = message.replace("%type%", type.getName().toUpperCase()).replace("%message%", LoggingColors.format(message, false));
private BukkitLogger sendUncolored(LogType type, String format, String message) throws IOException {
message = format.replace("%type%", type.getName().toUpperCase()).replace("%message%", LoggingColors.format(message, false));
if (custom != null) {
custom.accept(true, message);
}
Expand Down

0 comments on commit 1aba983

Please sign in to comment.