Updated more println to new logger

This commit is contained in:
Anthony committed 2018-02-28 20:17:08 -05:00
1 parent 84c8748731
commit 49e7f87d17
9 files changed
+22 -15

No files matched your search

+1
View File
@@ -63,6 +63,7 @@
<groupId>org.fusesource.jansi</groupId> <groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId> <artifactId>jansi</artifactId>
<version>1.17</version> <version>1.17</version>
<scope>runtime</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.sedmelluq</groupId> <groupId>com.sedmelluq</groupId>
@@ -1,5 +1,7 @@
package netneutrality.db; package netneutrality.db;
import netneutrality.MusicBot;
import java.sql.SQLException; import java.sql.SQLException;
public abstract class AbstractController { public abstract class AbstractController {
@@ -19,14 +21,14 @@ public abstract class AbstractController {
} }
public AbstractController start() { public AbstractController start() {
System.out.println("Starting task.. ["+ getControllerName() + "}"); MusicBot.LOGGER.debug("Starting task.. ["+ getControllerName() + "}");
DBController.isDoingSomething = true; DBController.isDoingSomething = true;
isDoingSomething = true; isDoingSomething = true;
return this; return this;
} }
protected AbstractController end() { protected AbstractController end() {
System.out.println("Ended task! ["+ getControllerName() + "}"); MusicBot.LOGGER.debug("Ended task! ["+ getControllerName() + "}");
DBController.isDoingSomething = false; DBController.isDoingSomething = false;
isDoingSomething = false; isDoingSomething = false;
return this; return this;
@@ -59,7 +59,7 @@ public class DBController {
public static MysqlDatabase get() { public static MysqlDatabase get() {
try { try {
if (database.isClosed()) { if (database.isClosed()) {
System.out.println("Reconnecting to database.."); MusicBot.LOGGER.info("Reconnecting to database..");
database.reconnect(); database.reconnect();
} }
} catch (SQLException e) { } catch (SQLException e) {
@@ -93,7 +93,7 @@ public class DBController {
* Loads all the controllers which extends {@link AbstractController} * Loads all the controllers which extends {@link AbstractController}
*/ */
private static void loadControllers() { private static void loadControllers() {
System.out.println("Loading databases controllers.."); MusicBot.LOGGER.info("Loading databases controllers..");
Reflections reflections = new Reflections("netneutrality.db.controllers"); Reflections reflections = new Reflections("netneutrality.db.controllers");
Set<Class<? extends AbstractController>> classes = reflections.getSubTypesOf(AbstractController.class); Set<Class<? extends AbstractController>> classes = reflections.getSubTypesOf(AbstractController.class);
@@ -109,7 +109,7 @@ public class DBController {
if (!controllers.containsKey(c.getControllerName())) { if (!controllers.containsKey(c.getControllerName())) {
controllers.put(c.getControllerName(), c); controllers.put(c.getControllerName(), c);
System.out.println("Loaded controller: " + c.getControllerName()); MusicBot.LOGGER.info("Loaded controller: " + c.getControllerName());
} }
} catch (NoSuchMethodException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException e) { } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException e) {
@@ -26,10 +26,10 @@ public class MysqlDatabase {
public MysqlDatabase(String dbName) { public MysqlDatabase(String dbName) {
this.dbName = dbName; this.dbName = dbName;
try { try {
System.out.println("Connecting to database..."); MusicBot.LOGGER.info("Connecting to database...");
connection = new MysqlConnector(dbName, "root", "localhost", "").connect().getConnection(); connection = new MysqlConnector(dbName, "root", "localhost", "").connect().getConnection();
} catch (SQLException e) { } catch (SQLException e) {
System.err.println("Error connecting to database. Shutting down.."); MusicBot.LOGGER.error("Error connecting to database. Shutting down..");
MusicBot.disconnect(); MusicBot.disconnect();
System.exit(0); System.exit(0);
} }
@@ -1,5 +1,7 @@
package netneutrality.handler; package netneutrality.handler;
import netneutrality.MusicBot;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@@ -8,7 +10,7 @@ public class ConsoleHandler {
public ConsoleHandler() { public ConsoleHandler() {
System.out.println("Console input ready!"); MusicBot.LOGGER.info("Console input ready!");
} }
public String init() throws IOException { public String init() throws IOException {
@@ -12,7 +12,7 @@ public class MessageRateLimit {
private static OffsetDateTime timestamp; private static OffsetDateTime timestamp;
private static int cooldown = 500000000; // 1 seconds = 1000000000 nanoseconds private static int cooldown = 500000000; // 1 seconds = 1000000000 nanoseconds
public static boolean check(MessageReceivedEvent event) { public synchronized static boolean check(MessageReceivedEvent event) {
if (event.getChannel() instanceof PrivateChannel) if (event.getChannel() instanceof PrivateChannel)
return false; return false;
@@ -8,6 +8,7 @@ import java.util.HashMap;
import java.util.Set; import java.util.Set;
import net.dv8tion.jda.core.entities.ChannelType; import net.dv8tion.jda.core.entities.ChannelType;
import netneutrality.MusicBot;
import netneutrality.command.Visibility; import netneutrality.command.Visibility;
import netneutrality.command.basic.HelpCommand; import netneutrality.command.basic.HelpCommand;
import org.reflections.Reflections; import org.reflections.Reflections;
@@ -101,7 +102,7 @@ public class NewCommandListener extends ListenerAdapter {
} }
private void initCommands() { private void initCommands() {
System.out.println("Loading commands.."); MusicBot.LOGGER.info("Loading commands..");
Reflections reflections = new Reflections("netneutrality.command"); Reflections reflections = new Reflections("netneutrality.command");
Set<Class<? extends AbstractCommand>> classes = reflections.getSubTypesOf(AbstractCommand.class); Set<Class<? extends AbstractCommand>> classes = reflections.getSubTypesOf(AbstractCommand.class);
@@ -126,7 +127,7 @@ public class NewCommandListener extends ListenerAdapter {
} }
} }
System.out.println("Loaded " + commands.size() + " commands!"); MusicBot.LOGGER.info("Loaded " + commands.size() + " commands!");
} }
private void initAlias() { private void initAlias() {
@@ -7,6 +7,7 @@ package netneutrality.http.server;
*/ */
import com.sun.net.httpserver.HttpServer; import com.sun.net.httpserver.HttpServer;
import netneutrality.MusicBot;
import java.io.IOException; import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
@@ -17,7 +18,7 @@ public class WebApi {
private HttpServer server; private HttpServer server;
public WebApi() { public WebApi() {
System.out.println("Starting web server..."); MusicBot.LOGGER.debug("Starting web server...");
try { try {
server = HttpServer.create(new InetSocketAddress(port), 0); server = HttpServer.create(new InetSocketAddress(port), 0);
} catch (IOException e) { } catch (IOException e) {
@@ -27,7 +28,7 @@ public class WebApi {
server.createContext("/guild", new GuildBrowser()); server.createContext("/guild", new GuildBrowser());
server.setExecutor(null); server.setExecutor(null);
server.start(); server.start();
System.out.println("Web server started at [" + server.getAddress().getAddress().toString() + "]"); MusicBot.LOGGER.debug("Web server started at [" + server.getAddress().getAddress().getAddress().toString() + "]");
} }
@@ -50,12 +50,12 @@ public class MusicManager {
return vChannel != null && vChannel.equals(MusicBot.getJDA().getGuildById(guildId).getAudioManager().getConnectedChannel()); return vChannel != null && vChannel.equals(MusicBot.getJDA().getGuildById(guildId).getAudioManager().getConnectedChannel());
} }
public void connect(VoiceChannel vChannel) { public synchronized void connect(VoiceChannel vChannel) {
if (vChannel != null && !isConnectedTo(vChannel)) { if (vChannel != null && !isConnectedTo(vChannel)) {
Guild guild = MusicBot.getJDA().getGuildById(guildId); Guild guild = MusicBot.getJDA().getGuildById(guildId);
guild.getAudioManager().openAudioConnection(vChannel); guild.getAudioManager().openAudioConnection(vChannel);
} else } else
MusicBot.LOGGER.debug("Error connecting!"); MusicBot.LOGGER.error("Error connecting!");
} }
public boolean isConnected() { public boolean isConnected() {