Mercurial Hosting > luan
diff src/luan/modules/lucene/PostgresBackup.java @ 1393:cc0dbca576dc
better logging
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 06 Sep 2019 05:09:56 -0600 |
parents | 002152af497a |
children | 67c0e47b5be3 |
line wrap: on
line diff
--- a/src/luan/modules/lucene/PostgresBackup.java Fri Sep 06 00:19:47 2019 -0600 +++ b/src/luan/modules/lucene/PostgresBackup.java Fri Sep 06 05:09:56 2019 -0600 @@ -17,13 +17,14 @@ import luan.LuanException; import luan.modules.Utils; import luan.modules.parsers.LuanToString; -import luan.modules.logging.LuanLogger; import luan.lib.logging.Logger; import luan.lib.logging.LoggerFactory; final class PostgresBackup { - private static final Logger logger = LoggerFactory.getLogger(PostgresBackup.class); + private static final Logger sysLogger = LoggerFactory.getLogger(PostgresBackup.class); + + private final Logger luanLogger; final boolean wasCreated; private final String url; @@ -35,9 +36,10 @@ private int trans = 0; private final LuanToString luanToString = new LuanToString(); - PostgresBackup(Map spec) + PostgresBackup(Luan luan,Map spec) throws ClassNotFoundException, SQLException, LuanException { + this.luanLogger = luan.getLogger(PostgresBackup.class); /* Class.forName("org.postgresql.Driver"); url = "jdbc:postgresql://localhost:5432/luan"; @@ -98,7 +100,7 @@ protected void finalize() throws Throwable { super.finalize(); if( !con.isClosed() ) { - logger.error("con not closed"); + sysLogger.error("con not closed"); con.close(); } } @@ -118,8 +120,7 @@ updateStmt.setLong(2,id); int n = updateStmt.executeUpdate(); if( n==0 ) { - Logger logger = LuanLogger.getLogger(doc.luan(),PostgresBackup.class); - logger.error("update not found for id="+id+", trying add"); + luanLogger.error("update not found for id="+id+", trying add"); add(doc); } else if( n!=1 ) throw new RuntimeException();