perfsonar-dev - [pS-dev] [GEANT/SA2/ps-java-services] r5970 - in trunk/perfsonar-base3-persistence/src/main/java/net/geant/perfsonar: logging persistence
Subject: perfsonar development work
List archive
[pS-dev] [GEANT/SA2/ps-java-services] r5970 - in trunk/perfsonar-base3-persistence/src/main/java/net/geant/perfsonar: logging persistence
Chronological Thread
- From:
- To:
- Subject: [pS-dev] [GEANT/SA2/ps-java-services] r5970 - in trunk/perfsonar-base3-persistence/src/main/java/net/geant/perfsonar: logging persistence
- Date: Tue, 21 Aug 2012 11:48:10 +0100 (BST)
Author: nordunet.behrmann
Date: 2012-08-21 11:48:09 +0100 (Tue, 21 Aug 2012)
New Revision: 5970
Removed:
trunk/perfsonar-base3-persistence/src/main/java/net/geant/perfsonar/logging/Logger.java
Modified:
trunk/perfsonar-base3-persistence/src/main/java/net/geant/perfsonar/persistence/HibernateConfiguration.java
Log:
perfsonar-base3-persistence: Replace custom logging API with slf4j API
Rather than invent our own logging API, this patch updated the code
to use the slf4j API.
The change also ensure that database errors are logged rather than
ignored by a null logger.
Deleted:
trunk/perfsonar-base3-persistence/src/main/java/net/geant/perfsonar/logging/Logger.java
===================================================================
---
trunk/perfsonar-base3-persistence/src/main/java/net/geant/perfsonar/logging/Logger.java
2012-08-21 10:48:09 UTC (rev 5969)
+++
trunk/perfsonar-base3-persistence/src/main/java/net/geant/perfsonar/logging/Logger.java
2012-08-21 10:48:09 UTC (rev 5970)
@@ -1,12 +0,0 @@
-package net.geant.perfsonar.logging;
-
-/**
- * @author <a
href="mailto:">Blazej
Pietrzak</a>
- */
-public interface Logger {
-
- void info(String message, Object... args);
-
- void error(Exception ex, String message, Object... args);
-
-}
Modified:
trunk/perfsonar-base3-persistence/src/main/java/net/geant/perfsonar/persistence/HibernateConfiguration.java
===================================================================
---
trunk/perfsonar-base3-persistence/src/main/java/net/geant/perfsonar/persistence/HibernateConfiguration.java
2012-08-21 10:48:09 UTC (rev 5969)
+++
trunk/perfsonar-base3-persistence/src/main/java/net/geant/perfsonar/persistence/HibernateConfiguration.java
2012-08-21 10:48:09 UTC (rev 5970)
@@ -12,12 +12,13 @@
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
-import net.geant.perfsonar.logging.Logger;
-
import org.hibernate.ejb.Ejb3Configuration;
import com.mchange.v2.c3p0.ComboPooledDataSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* Configuration for JPA-Hibernate implementation.
*
@@ -27,15 +28,8 @@
* @author <a
href="mailto:">Blazej
Pietrzak</a>
*/
public class HibernateConfiguration {
- protected static final Logger nullLogger = new Logger() {
- @Override
- public void info(String message, Object... args) { }
-
- @Override
- public void error(Exception ex, String message, Object...
args) { }
- };
-
- private Logger logger = nullLogger;
+
+ private Logger logger =
LoggerFactory.getLogger(HibernateConfiguration.class);
private URI dbUri;
private Driver driver;
private int poolTimeout = 5000;
@@ -45,14 +39,6 @@
private String dialect;
private Collection<Class<?>> classes = new ArrayList<Class<?>>();
- public Logger getLogger() {
- return logger;
- }
-
- public void setLogger(Logger logger) {
- this.logger = logger;
- }
-
public URI getDbUri() {
return dbUri;
}
@@ -221,7 +207,7 @@
}
}
- logger.info("Connected to %s", ds.getJdbcUrl());
+ logger.info("Connected to {}", ds.getJdbcUrl());
return ds;
}
@@ -232,10 +218,10 @@
cfg.setDataSource(createDataSource(user, password));
} catch (Exception e) {
if (e.getCause() instanceof InterruptedException) {
- logger.error(e, "Cannot connected to the database. Check
the configuration.");
- } else
- logger.error(e, "Cannot connect to the database: %s",
e.getMessage());
-
+ logger.error("Cannot connected to the database. Check the
configuration.", e);
+ } else {
+ logger.error("Cannot connect to the database: " +
e.getMessage(), e);
+ }
return null;
}
- [pS-dev] [GEANT/SA2/ps-java-services] r5970 - in trunk/perfsonar-base3-persistence/src/main/java/net/geant/perfsonar: logging persistence, svn-noreply, 08/21/2012
Archive powered by MHonArc 2.6.16.