mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 11:40:40 +00:00
Fix NPE in ErrorLogFilter, Update Error Logger to v2.0.2
This commit is contained in:
parent
f9f8d851e3
commit
58d963fe64
4 changed files with 38 additions and 36 deletions
|
@ -1,33 +1,35 @@
|
|||
package com.projectkorra.ProjectKorra.Utilities.logging;
|
||||
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
/**
|
||||
* Not to be confused with {@link LogFilter}, {@code ErrorLogFilter} is
|
||||
* a subclass of {@link LogFilter}.
|
||||
* <p>
|
||||
* Can NOT and SHOULD NOT be used as a filter for {@code plugin.getLogger().getParent()}
|
||||
* If used in such way, unnecessary {@link LogRecord} may be logged to file
|
||||
* </p>
|
||||
*
|
||||
* @author Jacklin213
|
||||
* @version 2.0.1
|
||||
*/
|
||||
public class ErrorLogFilter extends LogFilter {
|
||||
|
||||
@Override
|
||||
public boolean isLoggable(LogRecord record) {
|
||||
if (consoleError.contains(record.getMessage().replace("[ProjectKorra] ", ""))) {
|
||||
return false;
|
||||
} else if (!record.getMessage().contains("ProjectKorra")) {
|
||||
if (record.getThrown() != null && record.getThrown().getMessage() != null) {
|
||||
if (record.getThrown().getMessage().contains("ProjectKorra")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
package com.projectkorra.ProjectKorra.Utilities.logging;
|
||||
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
/**
|
||||
* Not to be confused with {@link LogFilter}, {@code ErrorLogFilter} is
|
||||
* a subclass of {@link LogFilter}.
|
||||
* <p>
|
||||
* Can NOT and SHOULD NOT be used as a filter for {@code plugin.getLogger().getParent()}
|
||||
* If used in such way, unnecessary {@link LogRecord} may be logged to file
|
||||
* </p>
|
||||
*
|
||||
* @author Jacklin213
|
||||
* @version 2.0.2
|
||||
*/
|
||||
public class ErrorLogFilter extends LogFilter {
|
||||
|
||||
@Override
|
||||
public boolean isLoggable(LogRecord record) {
|
||||
if (consoleError.contains(record.getMessage().replace("[ProjectKorra] ", ""))) {
|
||||
return false;
|
||||
} else if (!record.getMessage().contains("ProjectKorra")) {
|
||||
if (record.getThrown() != null) {
|
||||
if (record.getThrown().getMessage() != null ) {
|
||||
if (record.getThrown().getMessage().contains("ProjectKorra")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import com.projectkorra.ProjectKorra.ProjectKorra;
|
|||
* To set the filter for PKLogHandler use {@link PKLogFilter}
|
||||
* </p>
|
||||
* @author Jacklin213
|
||||
* @version 2.0.1
|
||||
* @version 2.0.2
|
||||
*/
|
||||
public class LogFilter implements Filter {
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.logging.LogRecord;
|
|||
* Logger formatter class based on bukkit's formatter
|
||||
*
|
||||
* @author Jacklin213
|
||||
* @version 2.0.1
|
||||
* @version 2.0.2
|
||||
*/
|
||||
public class LogFormatter extends Formatter {
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import java.util.logging.Level;
|
|||
* <li>Formatter - {@link LogFormatter}</li>
|
||||
* </ul>
|
||||
* @author Jacklin213
|
||||
* @version 2.0.1
|
||||
* @version 2.0.2
|
||||
*/
|
||||
public class PKLogHandler extends FileHandler {
|
||||
|
||||
|
|
Loading…
Reference in a new issue