mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-02-14 19:42:12 +01:00
DebugLog: No more duplicates and you can now modify the log-tag.
This commit is contained in:
parent
9eccf93b66
commit
a60e4e06e1
@ -26,9 +26,9 @@ import java.util.logging.Logger;
|
|||||||
* The Multiverse debug-logger.
|
* The Multiverse debug-logger.
|
||||||
*/
|
*/
|
||||||
public class DebugLog extends Logger {
|
public class DebugLog extends Logger {
|
||||||
|
|
||||||
private FileHandler fh;
|
private FileHandler fh;
|
||||||
private Logger standardLog = null;
|
private Logger standardLog = null;
|
||||||
|
private String prefix = "[MVCore-Debug] ";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new debug logger.
|
* Creates a new debug logger.
|
||||||
@ -55,6 +55,14 @@ public class DebugLog extends Logger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the log-tag.
|
||||||
|
* @param tag The new tag.
|
||||||
|
*/
|
||||||
|
public void setTag(String tag) {
|
||||||
|
this.prefix = tag + " ";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies the logger to use to send debug messages to as the debug logger itself only sends messages to a file.
|
* Specifies the logger to use to send debug messages to as the debug logger itself only sends messages to a file.
|
||||||
*
|
*
|
||||||
@ -70,12 +78,15 @@ public class DebugLog extends Logger {
|
|||||||
* @param level The log-{@link Level}.
|
* @param level The log-{@link Level}.
|
||||||
* @param msg the message.
|
* @param msg the message.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void log(Level level, String msg) {
|
public void log(Level level, String msg) {
|
||||||
if (MultiverseCoreConfiguration.isSet() && MultiverseCoreConfiguration.getInstance().getGlobalDebug() > 0) {
|
if (MultiverseCoreConfiguration.isSet() && MultiverseCoreConfiguration.getInstance().getGlobalDebug() > 0) {
|
||||||
if (standardLog != null) {
|
// only redirect to standardLog if it's lower than INFO so we don't log that twice!
|
||||||
standardLog.log(level, "[MVCore-Debug] " + msg);
|
if ((level.intValue() < Level.INFO.intValue()) && (standardLog != null)) {
|
||||||
|
standardLog.log(level, prefix + msg);
|
||||||
}
|
}
|
||||||
super.log(level, "[MVCore-Debug] " + msg);
|
|
||||||
|
super.log(level, prefix + msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user