]> jfr.im git - irc/rizon/acid.git/blobdiff - acid/src/main/java/net/rizon/acid/sql/SQL.java
Convert logging to slf4j, and logback
[irc/rizon/acid.git] / acid / src / main / java / net / rizon / acid / sql / SQL.java
index 4fcb8d1307abd8b568af1819372722423e3e03f2..562b680ec93fd61c1c610df3c8471cafd3208d64 100644 (file)
@@ -6,15 +6,14 @@ import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.LinkedList;
-import java.util.logging.Level;
-
 import net.rizon.acid.conf.Database;
 import net.rizon.acid.core.Acidictive;
-import net.rizon.acid.core.Logger;
+import org.slf4j.LoggerFactory;
 
 public class SQL extends Thread
 {
-       private static final Logger log = Logger.getLogger(SQL.class.getName());
+       private static final org.slf4j.Logger log = LoggerFactory.getLogger(SQL.class);
+
        private PreparedStatement statement;
        private ResultSet result;
        private String url, username, password;
@@ -51,7 +50,7 @@ public class SQL extends Thread
        {
                this.shuttingDown = true;
 
-               log.log(Level.INFO, "Flushing pending SQL queries...");
+               log.info("Flushing pending SQL queries...");
 
                synchronized (this.queryLock)
                {
@@ -67,7 +66,7 @@ public class SQL extends Thread
                        catch (InterruptedException ex) { }
                }
 
-               log.log(Level.INFO, "All SQL queries successfully flushed");
+               log.info("All SQL queries successfully flushed");
 
                try { this.con.close(); }
                catch (Exception ex) { }
@@ -80,7 +79,7 @@ public class SQL extends Thread
                this.last_connect = System.currentTimeMillis();
                this.con = DriverManager.getConnection(this.url, this.username, this.password);
 
-               log.log(Level.INFO, "Successfully connected to " + this.version() + " using " + this.con.getMetaData().getDriverName() + " (" + this.con.getMetaData().getDriverVersion() + ")");
+               log.info("Successfully connected to " + this.version() + " using " + this.con.getMetaData().getDriverName() + " (" + this.con.getMetaData().getDriverVersion() + ")");
        }
 
        public PreparedStatement prepare(final String statement) throws SQLException
@@ -119,7 +118,7 @@ public class SQL extends Thread
        public int executeUpdateBlocking(PreparedStatement statement) throws SQLException
        {
                int i = statement.executeUpdate();
-               log.log(Level.FINE, "Successfully executed " + statement);
+               log.debug("Successfully executed " + statement);
                return i;
        }
 
@@ -127,7 +126,7 @@ public class SQL extends Thread
        {
                this.result = statement.executeQuery();
 
-               log.log(Level.FINE, "Successfully executed " + statement);
+               log.debug("Successfully executed " + statement);
 
                return this.result;
        }
@@ -194,7 +193,7 @@ public class SQL extends Thread
                                        q.executeUpdate();
                                        lastQuery = System.currentTimeMillis();
 
-                                       log.log(Level.FINE, "Successfully executed " + q + " in worker thread");
+                                       log.debug("Successfully executed " + q + " in worker thread");
                                }
                                catch (SQLException ex)
                                {
@@ -226,7 +225,7 @@ public class SQL extends Thread
                long now = System.currentTimeMillis() / 1000L;
                if (lastWarn + 60 < now)
                {
-                       log.log(Level.SEVERE, reason, ex);
+                       log.error(reason, ex);
                        lastWarn = now;
                }
        }