use of com.elmakers.mine.bukkit.api.event.MagicErrorEvent in project MagicPlugin by elBukkit.
the class MagicLogger method log.
@Override
public void log(LogRecord record) {
if (silent)
return;
if (!capture || (!record.getLevel().equals(Level.WARNING) && !record.getLevel().equals(Level.SEVERE)) || record.getThrown() != null) {
super.log(record);
}
Server server = Bukkit.getServer();
CompatibilityUtils compatibility = CompatibilityLib.isInitialized() ? CompatibilityLib.getCompatibilityUtils() : null;
String message = record.getMessage();
if (message != null) {
message = message.replace("[Magic] ", "");
}
LogMessage logMessage = new LogMessage(context, message);
if (record.getLevel().equals(Level.WARNING)) {
synchronized (warnings) {
pendingWarningCount++;
warnings.add(logMessage);
if (server != null) {
MagicWarningEvent event = new MagicWarningEvent(record, context, pendingWarningCount, capture);
if (compatibility != null && compatibility.isPrimaryThread()) {
server.getPluginManager().callEvent(event);
} else if (plugin != null && plugin.isEnabled()) {
server.getScheduler().runTask(plugin, new CallEventTask(event));
}
}
}
} else if (record.getLevel().equals(Level.SEVERE)) {
synchronized (errors) {
pendingErrorCount++;
errors.add(logMessage);
if (server != null) {
MagicErrorEvent event = new MagicErrorEvent(record, context, pendingErrorCount, capture);
if (compatibility != null && compatibility.isPrimaryThread()) {
server.getPluginManager().callEvent(event);
} else if (plugin != null && plugin.isEnabled()) {
server.getScheduler().runTask(plugin, new CallEventTask(event));
}
}
}
}
}
Aggregations