Better logging for secondary storage problems.
This commit is contained in:
parent
e23d8a956a
commit
b3cac816c6
|
|
@ -80,6 +80,7 @@ class CustomLogger
|
||||||
|
|
||||||
private boolean isEnabledType(CustomLogEntryTypes entryType)
|
private boolean isEnabledType(CustomLogEntryTypes entryType)
|
||||||
{
|
{
|
||||||
|
if(entryType == CustomLogEntryTypes.Exception) return true;
|
||||||
if(entryType == CustomLogEntryTypes.SocialActivity && !GriefPrevention.instance.config_logs_socialEnabled) return false;
|
if(entryType == CustomLogEntryTypes.SocialActivity && !GriefPrevention.instance.config_logs_socialEnabled) return false;
|
||||||
if(entryType == CustomLogEntryTypes.SuspiciousActivity && !GriefPrevention.instance.config_logs_suspiciousEnabled) return false;
|
if(entryType == CustomLogEntryTypes.SuspiciousActivity && !GriefPrevention.instance.config_logs_suspiciousEnabled) return false;
|
||||||
if(entryType == CustomLogEntryTypes.AdminActivity && !GriefPrevention.instance.config_logs_adminEnabled) return false;
|
if(entryType == CustomLogEntryTypes.AdminActivity && !GriefPrevention.instance.config_logs_adminEnabled) return false;
|
||||||
|
|
@ -185,5 +186,6 @@ enum CustomLogEntryTypes
|
||||||
SocialActivity,
|
SocialActivity,
|
||||||
SuspiciousActivity,
|
SuspiciousActivity,
|
||||||
AdminActivity,
|
AdminActivity,
|
||||||
Debug
|
Debug,
|
||||||
|
Exception
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
package me.ryanhamshire.GriefPrevention;
|
package me.ryanhamshire.GriefPrevention;
|
||||||
|
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.StringWriter;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
|
@ -514,9 +516,9 @@ public class DatabaseDataStore extends DataStore
|
||||||
}
|
}
|
||||||
catch(SQLException e)
|
catch(SQLException e)
|
||||||
{
|
{
|
||||||
GriefPrevention.AddLogEntry("Unable to retrieve data for player " + playerID.toString() + ". Details:");
|
StringWriter errors = new StringWriter();
|
||||||
GriefPrevention.AddLogEntry(e.getMessage());
|
e.printStackTrace(new PrintWriter(errors));
|
||||||
e.printStackTrace();
|
GriefPrevention.AddLogEntry(playerID + " " + errors.toString(), CustomLogEntryTypes.Exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
return playerData;
|
return playerData;
|
||||||
|
|
@ -548,8 +550,9 @@ public class DatabaseDataStore extends DataStore
|
||||||
}
|
}
|
||||||
catch(SQLException e)
|
catch(SQLException e)
|
||||||
{
|
{
|
||||||
GriefPrevention.AddLogEntry("Unable to save data for player " + playerID.toString() + ". Details:");
|
StringWriter errors = new StringWriter();
|
||||||
GriefPrevention.AddLogEntry(e.getMessage());
|
e.printStackTrace(new PrintWriter(errors));
|
||||||
|
GriefPrevention.AddLogEntry(playerID + " " + errors.toString(), CustomLogEntryTypes.Exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,9 @@ public class FlatFileDataStore extends DataStore
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
GriefPrevention.AddLogEntry("Unable to load group bonus block data from file \"" + file.getName() + "\": " + e.getMessage());
|
StringWriter errors = new StringWriter();
|
||||||
|
e.printStackTrace(new PrintWriter(errors));
|
||||||
|
GriefPrevention.AddLogEntry(errors.toString(), CustomLogEntryTypes.Exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
@ -340,8 +342,9 @@ public class FlatFileDataStore extends DataStore
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GriefPrevention.AddLogEntry("Unable to load data for claim \"" + files[i].getName() + "\": " + e.toString());
|
StringWriter errors = new StringWriter();
|
||||||
e.printStackTrace();
|
e.printStackTrace(new PrintWriter(errors));
|
||||||
|
GriefPrevention.AddLogEntry(files[i].getName() + " " + errors.toString(), CustomLogEntryTypes.Exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -384,8 +387,9 @@ public class FlatFileDataStore extends DataStore
|
||||||
//if any problem, log it
|
//if any problem, log it
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
GriefPrevention.AddLogEntry("Unexpected exception saving data for claim \"" + claimID + "\": " + e.toString());
|
StringWriter errors = new StringWriter();
|
||||||
e.printStackTrace();
|
e.printStackTrace(new PrintWriter(errors));
|
||||||
|
GriefPrevention.AddLogEntry(claimID + " " + errors.toString(), CustomLogEntryTypes.Exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
//close the file
|
//close the file
|
||||||
|
|
@ -542,8 +546,9 @@ public class FlatFileDataStore extends DataStore
|
||||||
//if last attempt failed, log information about the problem
|
//if last attempt failed, log information about the problem
|
||||||
if(needRetry)
|
if(needRetry)
|
||||||
{
|
{
|
||||||
GriefPrevention.AddLogEntry("Retry attempts exhausted. Unable to load data for player \"" + playerID.toString() + "\": " + latestException.toString());
|
StringWriter errors = new StringWriter();
|
||||||
latestException.printStackTrace();
|
latestException.printStackTrace(new PrintWriter(errors));
|
||||||
|
GriefPrevention.AddLogEntry(playerID + " " + errors.toString(), CustomLogEntryTypes.Exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user