Skip to content

Commit

Permalink
Make SQL output verbosable
Browse files Browse the repository at this point in the history
That's a word now, I declare it
  • Loading branch information
mcmonkey4eva committed Jan 14, 2015
1 parent 6fc7716 commit 80ddc90
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Expand Up @@ -197,7 +197,8 @@ public void debug(CommandContext args, CommandSender sender) throws CommandExcep
}
if (args.hasFlag('r')) {
if (!dB.showDebug) dB.toggle();
dB.verbose = !dB.verbose;
net.aufdemrand.denizencore.utilities.debugging.dB.verbose =
!net.aufdemrand.denizencore.utilities.debugging.dB.verbose;
Messaging.sendInfo(sender, (dB.record ? "Denizen dBugger is now verbose.":
"Denizen dBugger verbosity disabled."));
}
Expand Down
Expand Up @@ -7,7 +7,7 @@
import net.aufdemrand.denizencore.scripts.commands.AbstractCommand;
import net.aufdemrand.denizencore.scripts.commands.Holdable;
import net.aufdemrand.denizen.utilities.DenizenAPI;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizencore.utilities.debugging.dB;
import org.bukkit.Bukkit;

import java.sql.*;
Expand Down Expand Up @@ -129,6 +129,7 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept
@Override
public void run() {
Connection con = null;
if (dB.verbose) dB.echoDebug(scriptEntry, "Connecting to " + server.asString());
try {
con = getConnection(username.asString(), password.asString(), server.asString());
}
Expand All @@ -138,9 +139,11 @@ public void run() {
public void run() {
dB.echoError(scriptEntry.getResidingQueue(), "SQL Exception: " + e.getMessage());
scriptEntry.setFinished(true);
if (dB.verbose) dB.echoError(scriptEntry.getResidingQueue(), e);
}
}, 1);
}
if (dB.verbose) dB.echoDebug(scriptEntry, "Connection did not error");
final Connection conn = con;
if (con != null) {
Bukkit.getScheduler().runTaskLater(DenizenAPI.getCurrentInstance(), new Runnable() {
Expand All @@ -152,6 +155,15 @@ public void run() {
}
}, 1);
}
else {
Bukkit.getScheduler().runTaskLater(DenizenAPI.getCurrentInstance(), new Runnable() {
@Override
public void run() {
scriptEntry.setFinished(true);
if (dB.verbose) dB.echoDebug(scriptEntry, "Connecting errored!");
}
}, 1);
}
}
}, 1);
}
Expand Down Expand Up @@ -222,6 +234,7 @@ else if (action.asString().equalsIgnoreCase("update")) {
}
rows.add(current.toString());
}
// TODO: add(count)?
scriptEntry.addObject("result", rows);
dB.echoDebug(scriptEntry, "Updated " + affected + " rows");
}
Expand All @@ -231,6 +244,7 @@ else if (action.asString().equalsIgnoreCase("update")) {
}
catch (SQLException e) {
dB.echoError(scriptEntry.getResidingQueue(), "SQL Exception: " + e.getMessage());
if (dB.verbose) dB.echoError(scriptEntry.getResidingQueue(), e);
}
}

Expand Down
Expand Up @@ -68,7 +68,6 @@ public class dB {
public static boolean showStackTraces = true;
public static boolean showColor = true;
public static boolean debugOverride = false;
public static boolean verbose = false;

public static List<String> filter = new ArrayList<String>();

Expand Down

0 comments on commit 80ddc90

Please sign in to comment.