Skip to content

Commit

Permalink
Merge pull request #179 from hazendaz/master
Browse files Browse the repository at this point in the history
Use real logger slf4j
  • Loading branch information
hazendaz authored Apr 6, 2024
2 parents 7a04150 + 6353c32 commit 1eb2fe1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
29 changes: 28 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
SPDX-License-Identifier: EPL-2.0
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.revelc.code</groupId>
Expand Down Expand Up @@ -50,4 +50,31 @@ SPDX-License-Identifier: EPL-2.0
<!-- rat plugin is no good at validating EPL headers out of the box -->
<rat.skip>true</rat.skip>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.36</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<ignoredUnusedDeclaredDependencies>
<!-- ignore sfl4j-simple as required for testing -->
<ignore>org.slf4j:slf4j-simple</ignore>
</ignoredUnusedDeclaredDependencies>
</configuration>
</plugin>
</plugins>
</build>
</project>
6 changes: 6 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import javax.xml.XMLConstants;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
Expand All @@ -25,6 +27,8 @@

public class XmlDocumentFormatter {

private static final Logger logger = LoggerFactory.getLogger(XmlDocumentFormatter.class);

private final String fDefaultLineDelimiter;
private final FormattingPreferences prefs;

Expand Down Expand Up @@ -109,7 +113,8 @@ public String format(String documentText) {
}
reader.close();
} catch (IOException e) {
System.out.println(e.getMessage());
logger.error("{}", e.getMessage());
logger.debug("", e);
}
return state.out.toString();
}
Expand All @@ -129,12 +134,13 @@ private void validateWellFormedness(String documentText) {
XMLReader reader = parser.getXMLReader();
reader.setErrorHandler(errorHandler);
reader.parse(new InputSource(new StringReader(documentText)));
} catch (Exception exception) {
if (!(exception instanceof SAXParseException)
} catch (Exception e) {
if (!(e instanceof SAXParseException)
|| !prefs.getWellFormedValidation().equals(FormattingPreferences.WARN)) {
throw new IllegalArgumentException(exception);
throw new IllegalArgumentException(e);
}
System.err.println("WARN: " + exception.getMessage());
logger.error("WARN: {}", e.getMessage());
logger.debug("", e);
}
}

Expand Down

0 comments on commit 1eb2fe1

Please sign in to comment.