public class DetailedErrorReporter extends java.lang.Object implements ErrorReporter
Modifier and Type | Field and Description |
---|---|
protected boolean |
apacheCommonsMissing |
static int |
DEFAULT_MAX_ERROR_COUNT |
static java.lang.String |
DEFAULT_PREFIX |
static java.lang.String |
DEFAULT_SUPPORT_URL |
static java.lang.String |
ERROR_PERMISSION |
protected java.util.Map<java.lang.String,java.lang.Object> |
globalParameters |
protected java.util.concurrent.atomic.AtomicInteger |
internalErrorCount |
protected java.util.logging.Logger |
logger |
protected int |
maxErrorCount |
protected java.lang.String |
pluginName |
protected java.lang.ref.WeakReference<org.bukkit.plugin.Plugin> |
pluginReference |
protected java.lang.String |
prefix |
static ReportType |
REPORT_EXCEPTION_COUNT
Report format for printing the current exception count.
|
static java.lang.String |
SECOND_LEVEL_PREFIX |
protected java.lang.String |
supportURL |
Constructor and Description |
---|
DetailedErrorReporter(org.bukkit.plugin.Plugin plugin)
Create a default error reporting system.
|
DetailedErrorReporter(org.bukkit.plugin.Plugin plugin,
java.lang.String prefix,
java.lang.String supportURL)
Create a central error reporting system.
|
DetailedErrorReporter(org.bukkit.plugin.Plugin plugin,
java.lang.String prefix,
java.lang.String supportURL,
int maxErrorCount,
java.util.logging.Logger logger)
Create a central error reporting system.
|
Modifier and Type | Method and Description |
---|---|
void |
addGlobalParameter(java.lang.String key,
java.lang.Object value)
Adds the given global parameter.
|
protected java.lang.String |
addPrefix(java.lang.String text,
java.lang.String prefix)
Adds the given prefix to every line in the text.
|
void |
clearGlobalParameters()
Reset all global parameters.
|
int |
getErrorCount()
Retrieve the current number of errors printed through
reportDetailed(Object, Report) . |
java.lang.Object |
getGlobalParameter(java.lang.String key)
Retrieve a global parameter by its key.
|
java.util.logging.Logger |
getLogger()
Retrieve the current logger that is used to print all reports.
|
int |
getMaxErrorCount()
Retrieve the maximum number of errors we can print before we begin suppressing errors.
|
java.lang.String |
getPrefix()
Retrieve the prefix to apply to every line in the error reports.
|
protected java.lang.String |
getStringDescription(java.lang.Object value)
Retrieve a string representation of the given object.
|
java.lang.String |
getSupportURL()
Retrieve the support URL that will be added to all detailed reports.
|
java.util.Set<java.lang.String> |
globalParameters()
Retrieve a set of every registered global parameter.
|
protected boolean |
isSimpleType(java.lang.Object test)
Determine if the given object is a wrapper for a primitive/simple type or not.
|
void |
reportDetailed(java.lang.Object sender,
Report.ReportBuilder reportBuilder)
Prints a detailed error report about an unhandled exception.
|
void |
reportDetailed(java.lang.Object sender,
Report report)
Prints a detailed error report about an unhandled exception.
|
void |
reportMinimal(org.bukkit.plugin.Plugin sender,
java.lang.String methodName,
java.lang.Throwable error)
Prints a small minimal error report regarding an exception from another plugin.
|
void |
reportMinimal(org.bukkit.plugin.Plugin sender,
java.lang.String methodName,
java.lang.Throwable error,
java.lang.Object... parameters)
Prints a small minimal error report regarding an exception from another plugin.
|
boolean |
reportMinimalNoSpam(org.bukkit.plugin.Plugin sender,
java.lang.String methodName,
java.lang.Throwable error)
Report a problem with a given method and plugin, ensuring that we don't exceed the maximum number of error reports.
|
void |
reportWarning(java.lang.Object sender,
Report.ReportBuilder reportBuilder)
Prints a warning message from the current plugin.
|
void |
reportWarning(java.lang.Object sender,
Report report)
Prints a warning message from the current plugin.
|
void |
setErrorCount(int errorCount)
Set the number of errors printed.
|
void |
setLogger(java.util.logging.Logger logger)
Set the current logger that is used to print all reports.
|
void |
setMaxErrorCount(int maxErrorCount)
Set the maximum number of errors we can print before we begin suppressing errors.
|
void |
setPrefix(java.lang.String prefix)
Set the prefix to apply to every line in the error reports.
|
void |
setSupportURL(java.lang.String supportURL)
Set the support URL that will be added to all detailed reports.
|
public static final ReportType REPORT_EXCEPTION_COUNT
public static final java.lang.String SECOND_LEVEL_PREFIX
public static final java.lang.String DEFAULT_PREFIX
public static final java.lang.String DEFAULT_SUPPORT_URL
public static final java.lang.String ERROR_PERMISSION
public static final int DEFAULT_MAX_ERROR_COUNT
protected java.lang.String prefix
protected java.lang.String supportURL
protected java.util.concurrent.atomic.AtomicInteger internalErrorCount
protected int maxErrorCount
protected java.util.logging.Logger logger
protected java.lang.ref.WeakReference<org.bukkit.plugin.Plugin> pluginReference
protected java.lang.String pluginName
protected boolean apacheCommonsMissing
protected java.util.Map<java.lang.String,java.lang.Object> globalParameters
public DetailedErrorReporter(org.bukkit.plugin.Plugin plugin)
public DetailedErrorReporter(org.bukkit.plugin.Plugin plugin, java.lang.String prefix, java.lang.String supportURL)
plugin
- - the plugin owner.prefix
- - default line prefix.supportURL
- - URL to report the error.public DetailedErrorReporter(org.bukkit.plugin.Plugin plugin, java.lang.String prefix, java.lang.String supportURL, int maxErrorCount, java.util.logging.Logger logger)
plugin
- - the plugin owner.prefix
- - default line prefix.supportURL
- - URL to report the error.maxErrorCount
- - number of errors to print before giving up.logger
- - current logger.public void reportMinimal(org.bukkit.plugin.Plugin sender, java.lang.String methodName, java.lang.Throwable error, java.lang.Object... parameters)
ErrorReporter
reportMinimal
in interface ErrorReporter
sender
- - the other plugin.methodName
- - name of the caller method.error
- - the exception itself.parameters
- - any relevant parameters to print.public void reportMinimal(org.bukkit.plugin.Plugin sender, java.lang.String methodName, java.lang.Throwable error)
ErrorReporter
reportMinimal
in interface ErrorReporter
sender
- - the other plugin.methodName
- - name of the caller method.error
- - the exception itself.public boolean reportMinimalNoSpam(org.bukkit.plugin.Plugin sender, java.lang.String methodName, java.lang.Throwable error)
sender
- - the component that observed this exception.methodName
- - the method name.error
- - the error itself.public void reportWarning(java.lang.Object sender, Report.ReportBuilder reportBuilder)
ErrorReporter
reportWarning
in interface ErrorReporter
sender
- - the object containing the caller method.reportBuilder
- - an error report builder that will be used to get the report.public void reportWarning(java.lang.Object sender, Report report)
ErrorReporter
reportWarning
in interface ErrorReporter
sender
- - the object containing the caller method.report
- - an error report to include.public void reportDetailed(java.lang.Object sender, Report.ReportBuilder reportBuilder)
ErrorReporter
reportDetailed
in interface ErrorReporter
sender
- - the object containing the caller method.reportBuilder
- - an error report builder that will be used to get the report.public void reportDetailed(java.lang.Object sender, Report report)
ErrorReporter
reportDetailed
in interface ErrorReporter
sender
- - the object containing the caller method.report
- - an error report to include.protected java.lang.String addPrefix(java.lang.String text, java.lang.String prefix)
text
- - text to modify.prefix
- - prefix added to every line in the text.protected java.lang.String getStringDescription(java.lang.Object value)
value
- - object to convert.protected boolean isSimpleType(java.lang.Object test)
test
- - the object to test.public int getErrorCount()
reportDetailed(Object, Report)
.public void setErrorCount(int errorCount)
errorCount
- - new number of errors printed.public int getMaxErrorCount()
public void setMaxErrorCount(int maxErrorCount)
maxErrorCount
- - new max count.public void addGlobalParameter(java.lang.String key, java.lang.Object value)
Both key and value must be non-null.
key
- - name of parameter.value
- - the global parameter itself.public java.lang.Object getGlobalParameter(java.lang.String key)
key
- - key of the parameter to retrieve.public void clearGlobalParameters()
public java.util.Set<java.lang.String> globalParameters()
public java.lang.String getSupportURL()
public void setSupportURL(java.lang.String supportURL)
supportURL
- - the new support URL.public java.lang.String getPrefix()
public void setPrefix(java.lang.String prefix)
prefix
- - new prefix.public java.util.logging.Logger getLogger()
public void setLogger(java.util.logging.Logger logger)
logger
- - new logger.