aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/ss
diff options
context:
space:
mode:
authorMarius Volkhart <mariusvolkhart@apache.org>2021-02-21 20:57:25 +0000
committerMarius Volkhart <mariusvolkhart@apache.org>2021-02-21 20:57:25 +0000
commit259c9967efb354a0feff2a861ac8bd20582b6562 (patch)
treeba76a4f20503d97e77bdf18146d59e00a2369fb9 /src/testcases/org/apache/poi/ss
parent6d10f26718f84591671d7cafdcc009345b9c777e (diff)
downloadpoi-259c9967efb354a0feff2a861ac8bd20582b6562.tar.gz
poi-259c9967efb354a0feff2a861ac8bd20582b6562.zip
[bug-63046] Use Log4j 2 for logging
This removes the POILogger and POILogFactory mechanism for logging. This mechanism was created at a time when the Java landscape looked very different than it does today. Log4j 2 is an Apache Foundation project that is well maintained and is widely regarded as having good performance and capabilities. We use only the Log4j API artifact. This lets application developers choose how they want to capture logging events if at all. Integrations with Log4j 2 Core and Logback are available from the Log4j project. Closes #224 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1886770 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/ss')
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
index a82a2a8681..bcd8bf272a 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
@@ -17,6 +17,7 @@
package org.apache.poi.ss.usermodel;
+import static org.apache.logging.log4j.util.Unbox.box;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -38,6 +39,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.FileMagic;
import org.apache.poi.ss.ITestDataProvider;
@@ -48,8 +51,6 @@ import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.ss.util.PaneInformation;
import org.apache.poi.ss.util.SheetUtil;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@@ -57,7 +58,7 @@ import org.junit.jupiter.api.Test;
* A base class for bugzilla issues that can be described in terms of common ss interfaces.
*/
public abstract class BaseTestBugzillaIssues {
- private static final POILogger LOG = POILogFactory.getLogger(BaseTestBugzillaIssues.class);
+ private static final Logger LOG = LogManager.getLogger(BaseTestBugzillaIssues.class);
private static final String TEST_32 = "Some text with 32 characters to ";
private static final String TEST_255 = "Some very long text that is exactly 255 characters, which are allowed here, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla.....";
@@ -1388,7 +1389,7 @@ public abstract class BaseTestBugzillaIssues {
// Create a workbook
try (Workbook wb = _testDataProvider.createWorkbook(nrows+1)) {
final Sheet sh = wb.createSheet();
- LOG.log(POILogger.DEBUG, wb.getClass().getName(), " column autosizing timing...");
+ LOG.atDebug().log("{} column autosizing timing...", wb.getClass().getName());
final long t0 = time();
_testDataProvider.trackAllColumnsForAutosizing(sh);
@@ -1401,28 +1402,24 @@ public abstract class BaseTestBugzillaIssues {
}
final double populateSheetTime = delta(t0);
final double populateSheetTimePerCell_ns = (1000000 * populateSheetTime / (nrows * ncols));
- if (LOG.check(POILogger.DEBUG)) {
- LOG.log(POILogger.DEBUG, "Populate sheet time: ", populateSheetTime, " ms (", populateSheetTimePerCell_ns, " ns/cell)");
+ LOG.atDebug().log("Populate sheet time: {} ms ({} ns/cell)", populateSheetTime, populateSheetTimePerCell_ns);
- LOG.log(POILogger.DEBUG, "Autosizing...");
- }
+ LOG.atDebug().log("Autosizing...");
final long t1 = time();
for (int c = 0; c < ncols; c++) {
final long t2 = time();
sh.autoSizeColumn(c);
- LOG.log(POILogger.DEBUG, "Column ", c, " took ", delta(t2), " ms");
+ LOG.atDebug().log("Column {} took {} ms", box(c),delta(t2));
}
final double autoSizeColumnsTime = delta(t1);
final double autoSizeColumnsTimePerColumn = autoSizeColumnsTime / ncols;
final double bestFitWidthTimePerCell_ns = 1000000 * autoSizeColumnsTime / (ncols * nrows);
- if (LOG.check(POILogger.DEBUG)) {
- LOG.log(POILogger.DEBUG, "Auto sizing columns took a total of ", autoSizeColumnsTime, " ms (", autoSizeColumnsTimePerColumn, " ms per column)");
- LOG.log(POILogger.DEBUG, "Best fit width time per cell: ", bestFitWidthTimePerCell_ns, " ns");
- }
+ LOG.atDebug().log("Auto sizing columns took a total of {} ms ({} ms per column)", autoSizeColumnsTime, autoSizeColumnsTimePerColumn);
+ LOG.atDebug().log("Best fit width time per cell: {} ns", bestFitWidthTimePerCell_ns);
final double totalTime_s = (populateSheetTime + autoSizeColumnsTime) / 1000;
- LOG.log(POILogger.DEBUG, "Total time: ", totalTime_s, " s");
+ LOG.atDebug().log("Total time: {} s", totalTime_s);
}
//if (bestFitWidthTimePerCell_ns > 50000) {