Skip to content

Commit

Permalink
Migrated logging from JCL to SLF4J; updated dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorRodchenkov committed Feb 11, 2024
1 parent ec8a5d6 commit 3564cbb
Show file tree
Hide file tree
Showing 23 changed files with 134 additions and 97 deletions.
21 changes: 19 additions & 2 deletions biopax-validator-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
<groupId>org.apache.httpcomponents</groupId>
<artifactId>fluent-hc</artifactId>
<version>4.5.14</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
Expand All @@ -29,14 +35,25 @@
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>4.0.3</version>
<scope>runtime</scope>
</dependency>
<dependency>
<!-- httpcomponents use JCL -->
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.client.fluent.Executor;
Expand All @@ -18,6 +16,8 @@
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.biopax.validator.jaxb.Behavior;
import org.biopax.validator.jaxb.ValidatorResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Simple (example) BioPAX Validator client
Expand All @@ -27,7 +27,7 @@
*
*/
public class BiopaxValidatorClient {
private static final Log log = LogFactory.getLog(BiopaxValidatorClient.class);
private static final Logger log = LoggerFactory.getLogger(BiopaxValidatorClient.class);

/**
* Default BioPAX Validator's URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<outputPatternAsHeader>true</outputPatternAsHeader>
</encoder>
</appender>
<root level="info">
<root level="debug">
<appender-ref ref="console"/>
</root>
</configuration>
13 changes: 5 additions & 8 deletions biopax-validator-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.6.0</version>
<executions>
Expand Down Expand Up @@ -323,19 +324,15 @@
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<!-- due to org.obo in biopax-validator uses log4j impl -->
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<artifactId>log4j-over-slf4j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<!-- due to org.obo in biopax-validator uses log4j impl -->
<!-- obo and httpcomponents use JCL -->
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<artifactId>jcl-over-slf4j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.biopax.paxtools.normalizer.Normalizer;
import org.biopax.validator.api.beans.Behavior;
import org.biopax.validator.api.beans.Validation;
Expand All @@ -34,7 +34,7 @@ public class ValidatorController {

private ValidatorAdapter service;

private final static Log log = LogFactory.getLog(ValidatorController.class);
private final static Logger log = LoggerFactory.getLogger(ValidatorController.class);
private final static String NEWLINE = System.getProperty ( "line.separator" );

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.biopax.paxtools.controller.ModelUtils;
import org.biopax.paxtools.converter.LevelUpgrader;
import org.biopax.paxtools.io.SimpleIOHandler;
Expand Down Expand Up @@ -40,7 +40,7 @@
* @author rodche
*/
public class BiopaxValidator implements Validator {
private static final Log log = LogFactory.getLog(BiopaxValidator.class);
private static final Logger log = LoggerFactory.getLogger(BiopaxValidator.class);

@Autowired
private Set<Rule<?>> rules;
Expand Down Expand Up @@ -191,7 +191,7 @@ public void run() {
} catch (Throwable t) {
//if we're here, there is probably a bug in the rule or validator!
String id = validation.identify(obj);
log.fatal(rule + ".check(" + id
log.error(rule + ".check(" + id
+ ") threw the exception: " + t.toString(), t);
// anyway, report it almost normally (for a user to see this in the results too)
validation.addError(utils.createError(id, "exception",
Expand All @@ -204,27 +204,25 @@ public void run() {
private void execute(ExecutorService exec, final Set<Rule<?>> rules,
final Validation validation, final Object obj)
{
exec.execute(new Runnable() {
@SuppressWarnings("unchecked") //obj can be either Model or a BPE
public void run() {
for(Rule rule : rules) {
Behavior behavior = utils.getRuleBehavior(rule.getClass().getName(),
validation.getProfile());
if (behavior == Behavior.IGNORE)
continue; // skip disabled rule

try {
if (rule.canCheck(obj))
rule.check(validation, obj);
} catch (Throwable t) {
//if we're here, there is probably a bug in the rule or validator!
String id = validation.identify(obj);
log.fatal(rule + ".check(" + id
+ ") threw the exception: " + t.toString(), t);
// anyway, report it almost normally (for a user to see this in the results too)
validation.addError(utils.createError(id, "exception",
rule.getClass().getName(), null, false, t));
}
//obj can be either Model or a BPE
exec.execute(() -> {
for(Rule rule : rules) {
Behavior behavior = utils.getRuleBehavior(rule.getClass().getName(),
validation.getProfile());
if (behavior == Behavior.IGNORE)
continue; // skip disabled rule

try {
if (rule.canCheck(obj))
rule.check(validation, obj);
} catch (Throwable t) {
//if we're here, there is probably a bug in the rule or validator!
String id = validation.identify(obj);
log.error(rule + ".check(" + id
+ ") threw the exception: " + t.toString(), t);
// anyway, report it almost normally (for a user to see this in the results too)
validation.addError(utils.createError(id, "exception",
rule.getClass().getName(), null, false, t));
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import java.lang.reflect.Method;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
Expand All @@ -31,7 +31,7 @@
@Aspect
public class ExceptionsAspect extends AbstractAspect {

private static final Log log = LogFactory.getLog(ExceptionsAspect.class);
private static final Logger log = LoggerFactory.getLogger(ExceptionsAspect.class);

@Autowired
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import org.apache.commons.text.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.biopax.validator.api.ValidatorUtils;
import org.biopax.validator.api.beans.*;
import org.springframework.beans.factory.annotation.Configurable;
Expand All @@ -24,7 +24,7 @@
*/
@Configurable
public class CoreUtils implements ValidatorUtils {
private static final Log logger = LogFactory.getLog(CoreUtils.class);
private static final Logger logger = LoggerFactory.getLogger(CoreUtils.class);
public static final int DEFAULT_MAX_ERRORS = 10000;

private Locale locale;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import org.apache.commons.collections15.collection.CompositeCollection;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.biopax.paxtools.model.BioPAXFactory;
import org.biopax.paxtools.model.BioPAXLevel;
import org.biopax.paxtools.model.level3.ControlledVocabulary;
Expand Down Expand Up @@ -36,7 +36,7 @@
*/
public class OntologyUtils implements CvUtils, CvFactory, XrefUtils
{
private final static Log log = LogFactory.getLog(OntologyUtils.class);
private final static Logger log = LoggerFactory.getLogger(OntologyUtils.class);

//see the post-construct init() method, where the following fields get initialized
private OntologyManager ontologyManager;
Expand Down
19 changes: 19 additions & 0 deletions distr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,25 @@
<type>war</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<!-- obo and httpcomponents use JCL -->
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
</dependencies>

</project>
6 changes: 3 additions & 3 deletions distr/src/main/java/org/biopax/validator/Main.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.biopax.validator;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.biopax.paxtools.io.SimpleIOHandler;
import org.biopax.paxtools.model.Model;
import org.biopax.paxtools.normalizer.Normalizer;
Expand Down Expand Up @@ -31,7 +31,7 @@
* @author rodche
*/
public class Main {
static final Log log = LogFactory.getLog(Main.class);
static final Logger log = LoggerFactory.getLogger(Main.class);
static ApplicationContext ctx;
static boolean autofix = false;
static int maxErrors = 0;
Expand Down
3 changes: 0 additions & 3 deletions distr/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
<outputPatternAsHeader>true</outputPatternAsHeader>
</encoder>
</appender>
<!-- <logger name="org.springframework" level="info"/>-->
<!-- <logger name="AspectJ Weaver" level="info"/>-->
<!-- <logger name="org.biopax.ols" level="error"/>-->
<logger name="org.biopax.psidev" level="error"/>
<root level="info">
<appender-ref ref="console"/>
Expand Down
8 changes: 8 additions & 0 deletions obo-fetcher/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
<artifactId>jms</artifactId>
<groupId>javax.jms</groupId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.biopax.ols.impl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.biopax.ols.Annotation;
import org.biopax.ols.Constants;
import org.biopax.ols.DbXref;
Expand All @@ -27,7 +27,7 @@
* @author Richard Cote
*/
public abstract class BaseOBO2AbstractLoader implements Loader {
protected static Log logger = LogFactory.getLog(BaseOBO2AbstractLoader.class);
protected static Logger logger = LoggerFactory.getLogger(BaseOBO2AbstractLoader.class);
protected HashMap<String, Term> ontologyTerms = new HashMap<>(5000);
protected String ONTOLOGY_DEFINITION;
protected String FULL_NAME;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.biopax.ols.impl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.biopax.ols.Parser;
import org.obo.dataadapter.OBOAdapter;
import org.obo.dataadapter.OBOFileAdapter;
Expand All @@ -20,7 +20,7 @@
* @version $Id: AbstractParser.java,v 1.9 2008/04/16 13:49:44 rglcote Exp $
*/
public class OBO2FormatParser implements Parser {
private static Log logger = LogFactory.getLog(OBO2FormatParser.class);
private static Logger logger = LoggerFactory.getLogger(OBO2FormatParser.class);

private OBOSession session;

Expand Down
Loading

0 comments on commit 3564cbb

Please sign in to comment.