Se agrego informacion de logeo a SQLiteCajaDAO

This commit is contained in:
Daniel Cortes
2019-03-08 01:05:01 -03:00
parent 407fdc9571
commit 3baa38e201
3 changed files with 21 additions and 6 deletions

BIN
dist/Programa Caja.jar vendored

Binary file not shown.

View File

@@ -33,8 +33,11 @@ import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class SQLiteCajaDAO implements CajaDAO { public class SQLiteCajaDAO implements CajaDAO {
private static final Logger LOGGER = LogManager.getLogger(SQLiteCajaDAO.class);
private SQLiteConnectionHolder connectionHolder; private SQLiteConnectionHolder connectionHolder;
public SQLiteCajaDAO() { public SQLiteCajaDAO() {
@@ -58,6 +61,7 @@ public class SQLiteCajaDAO implements CajaDAO {
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
LOGGER.error("Error al intentar obtener todas las Cajas", e);
} }
return cajaList; return cajaList;
@@ -80,6 +84,7 @@ public class SQLiteCajaDAO implements CajaDAO {
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
LOGGER.error("Error al intentar conseguir la caja con id " + id, e);
} }
return Optional.ofNullable(caja); return Optional.ofNullable(caja);
} }
@@ -101,6 +106,7 @@ public class SQLiteCajaDAO implements CajaDAO {
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
LOGGER.error("Error al intentar conseguir la caja con fecha " + fecha, e);
} }
return Optional.ofNullable(caja); return Optional.ofNullable(caja);
} }
@@ -115,7 +121,6 @@ public class SQLiteCajaDAO implements CajaDAO {
ps.executeUpdate(); ps.executeUpdate();
} }
query = "select last_insert_rowid()";
try (PreparedStatement ps = conn.prepareStatement("select last_insert_rowid()")) { try (PreparedStatement ps = conn.prepareStatement("select last_insert_rowid()")) {
try (ResultSet rs = ps.executeQuery()) { try (ResultSet rs = ps.executeQuery()) {
rs.next(); rs.next();
@@ -124,6 +129,7 @@ public class SQLiteCajaDAO implements CajaDAO {
} }
} catch (SQLException e) { } catch (SQLException e) {
LOGGER.error("Error al intentar insertar la caja " + caja, e);
} }
} }
@@ -138,6 +144,7 @@ public class SQLiteCajaDAO implements CajaDAO {
ps.executeUpdate(); ps.executeUpdate();
} }
} catch (SQLException e) { } catch (SQLException e) {
LOGGER.error("Error al intentar actualizar la caja " + caja, e);
} }
} }
} }

View File

@@ -6,13 +6,21 @@ filters = threshold
filter.threshold.type = ThresholdFilter filter.threshold.type = ThresholdFilter
filter.threshold.level = debug filter.threshold.level = debug
appenders = console appenders = console, file
appender.console.type = Console appender.console.type = Console
appender.console.name = STDOUT appender.console.name = console
appender.console.layout.type = PatternLayout appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n appender.console.layout.pattern = %date{yyyy-MM-dd HH:mm:ss} [%level] [%logger{3}:%line] - %message %n
appender.file.type = File
appender.file.name = file
appender.file.fileName = logs/debug.log
appender.file.layout.type = PatternLayout
appender.file.layout.pattern = %date{yyyy-MM-dd HH:mm:ss} [%level] [%logger{3}:%line] - %message %n
rootLogger.level = debug rootLogger.level = debug
rootLogger.appenderRefs = stdout rootLogger.additivity = false
rootLogger.appenderRef.stdout.ref = STDOUT rootLogger.appenderRefs = console, file
rootLogger.appenderRef.stdout.ref = console
rootLogger.appenderRef.rolling.ref = file