Browse Source

fix Logging issues:

- don't use foreign class in Logger initialization
- update log statements to use MessageFormat syntax

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1915930 13f79535-47bb-0310-9956-ffa450edef68
pull/599/head
Axel Howind 2 months ago
parent
commit
39a1ced25e

+ 2
- 2
poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipSecureFile.java View File

@@ -119,7 +119,7 @@ public class ZipSecureFile extends ZipFile {
if (maxEntrySize < 0) {
throw new IllegalArgumentException("Max entry size must be greater than or equal to zero");
} else if (maxEntrySize > DEFAULT_MAX_ENTRY_SIZE) {
LOG.atWarn().log("setting max entry size greater than 4Gb can be risky; set to " + maxEntrySize + " bytes");
LOG.warn("setting max entry size greater than 4Gb can be risky; set to {} bytes", maxEntrySize);
}
MAX_ENTRY_SIZE = maxEntrySize;
}
@@ -183,7 +183,7 @@ public class ZipSecureFile extends ZipFile {
if (maxTextSize < 0) {
throw new IllegalArgumentException("Max text size must be greater than or equal to zero");
}else if (maxTextSize > DEFAULT_MAX_TEXT_SIZE) {
LOG.atWarn().log("setting max text size greater than " + DEFAULT_MAX_TEXT_SIZE + " can be risky; set to " + maxTextSize + " chars");
LOG.warn("setting max text size greater than {} can be risky; set to {} chars", DEFAULT_MAX_TEXT_SIZE, maxTextSize);
}
MAX_TEXT_SIZE = maxTextSize;
}

+ 2
- 2
poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java View File

@@ -170,8 +170,8 @@ public abstract class XDDFChartData {
if (categoryData != null && values != null) {
int numOfPoints = category.getPointCount();
if (numOfPoints != values.getPointCount()) {
LOGGER.warn("Category and values must have the same point count, but had " +
numOfPoints + " categories and " + values.getPointCount() + " values.");
LOGGER.warn("Category and values must have the same point count, but had {}" +
" categories and {} values.", numOfPoints, values.getPointCount());
}
}
this.categoryData = category;

+ 1
- 1
poi-ooxml/src/test/java/org/apache/poi/openxml4j/opc/TestRelationships.java View File

@@ -44,7 +44,7 @@ class TestRelationships {
private static final String SHEET_WITH_COMMENTS =
"/xl/worksheets/sheet1.xml";

private static final Logger LOG = LogManager.getLogger(TestPackageCoreProperties.class);
private static final Logger LOG = LogManager.getLogger(TestRelationships.class);

/**
* Test relationships are correctly loaded. This at the moment fails (as of r499)

+ 1
- 1
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/EscherPlaceholder.java View File

@@ -64,7 +64,7 @@ public class EscherPlaceholder extends EscherRecord {
unused = LittleEndian.getShort(data, offset+14);

if (bytesRemaining + 8 != 16) {
LOG.warn("Invalid header-data received, should have 8 bytes left, but had: " + bytesRemaining);
LOG.warn("Invalid header-data received, should have 8 bytes left, but had: {}", bytesRemaining);
}

return bytesRemaining + 8;

+ 5
- 5
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SSSlideInfoAtom.java View File

@@ -203,21 +203,21 @@ public class SSSlideInfoAtom extends RecordAtom {
ofs += _header.length;

if (LittleEndian.getShort(_header, 0) != 0) {
LOG.atDebug().log("Invalid data for SSSlideInfoAtom at offset 0: " + LittleEndian.getShort(_header, 0));
LOG.debug("Invalid data for SSSlideInfoAtom at offset 0: {}", LittleEndian.getShort(_header, 0));
}
if (LittleEndian.getShort(_header, 2) != RecordTypes.SSSlideInfoAtom.typeID) {
LOG.atDebug().log("Invalid data for SSSlideInfoAtom at offset 2: "+ LittleEndian.getShort(_header, 2));
LOG.debug("Invalid data for SSSlideInfoAtom at offset 2: {}", LittleEndian.getShort(_header, 2));
}
if (LittleEndian.getShort(_header, 4) != 0x10) {
LOG.atDebug().log("Invalid data for SSSlideInfoAtom at offset 4: "+ LittleEndian.getShort(_header, 4));
LOG.debug("Invalid data for SSSlideInfoAtom at offset 4: {}", LittleEndian.getShort(_header, 4));
}
if (LittleEndian.getShort(_header, 6) == 0) {
LOG.atDebug().log("Invalid data for SSSlideInfoAtom at offset 6: "+ LittleEndian.getShort(_header, 6));
LOG.debug("Invalid data for SSSlideInfoAtom at offset 6: {}", LittleEndian.getShort(_header, 6));
}

_slideTime = LittleEndian.getInt(source, ofs);
if (_slideTime < 0 || _slideTime > 86399000) {
LOG.atDebug().log("Invalid data for SSSlideInfoAtom - invalid slideTime: "+ _slideTime);
LOG.debug("Invalid data for SSSlideInfoAtom - invalid slideTime: {}", _slideTime);
}
ofs += LittleEndianConsts.INT_SIZE;
_soundIdRef = LittleEndian.getInt(source, ofs);

+ 1
- 1
poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OfficeArtContent.java View File

@@ -79,7 +79,7 @@ public final class OfficeArtContent {
int pos = offset;
pos += drawingGroupData.fillFields(data, pos, recordFactory);
if (drawingGroupData.getRecordId() == EscherRecordTypes.DGG_CONTAINER.typeID) {
LOG.atDebug().log("Invalid record-id for filling Escher records: " + drawingGroupData.getRecordId());
LOG.debug("Invalid record-id for filling Escher records: {}", drawingGroupData.getRecordId());
}

/*

+ 6
- 6
poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/StyleSheet.java View File

@@ -211,9 +211,9 @@ public final class StyleSheet {
@Deprecated
private void createPap(int istd, int nesting) {
if (nesting > MAX_PAPX_NESTING) {
LOG.warn("Encountered too deep nesting, cannot fully process stylesheet at " + istd +
" with more than " + MAX_PAPX_NESTING + " nested ParagraphProperties." +
" Some data could not be parsed.");
LOG.warn("Encountered too deep nesting, cannot fully process stylesheet at {}" +
" with more than {} nested ParagraphProperties." +
" Some data could not be parsed.", istd, MAX_PAPX_NESTING);
return;
}

@@ -268,9 +268,9 @@ public final class StyleSheet {
@Deprecated
private void createChp(int istd, int nesting) {
if (nesting > MAX_CHPX_NESTING) {
LOG.warn("Encountered too deep nesting, cannot fully process stylesheet at " + istd +
" with more than " + MAX_CHPX_NESTING + " nested CharacterProperties." +
" Some data could not be parsed.");
LOG.warn("Encountered too deep nesting, cannot fully process stylesheet at {}" +
" with more than {} nested CharacterProperties." +
" Some data could not be parsed.", istd, MAX_CHPX_NESTING);
return;
}


+ 3
- 3
poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToTextConverter.java View File

@@ -43,7 +43,7 @@ import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

public class TestWordToTextConverter {
private static final Logger LOG = LogManager.getLogger(WordToTextConverter.class);
private static final Logger LOG = LogManager.getLogger(TestWordToTextConverter.class);

private static final List<String> failingFiles = Arrays.asList(
// Excel file
@@ -97,13 +97,13 @@ public class TestWordToTextConverter {
@ParameterizedTest
@MethodSource("files")
void testAllFiles(File file) throws Exception {
LOG.info("Testing " + file);
LOG.info("Testing {}", file);
try (FileInputStream stream = new FileInputStream(file)) {
InputStream is = FileMagic.prepareToCheckMagic(stream);
FileMagic fm = FileMagic.valueOf(is);

if (fm != FileMagic.OLE2) {
LOG.info("Skip non-doc file " + file);
LOG.info("Skip non-doc file {}", file);

return;
}

+ 1
- 1
poi/src/main/java/org/apache/poi/ss/format/CellFormat.java View File

@@ -192,7 +192,7 @@ public class CellFormat {

parts.add(new CellFormatPart(locale, valueDesc));
} catch (RuntimeException e) {
LOG.log(Level.WARN, "Invalid format: " + CellFormatter.quote(m.group()), e);
LOG.warn("Invalid format: {}", CellFormatter.quote(m.group()), e);
parts.add(null);
}
}

+ 1
- 1
poi/src/main/java/org/apache/poi/ss/format/CellFormatPart.java View File

@@ -256,7 +256,7 @@ public class CellFormatPart {
return null;
Color c = NAMED_COLORS.get(cdesc);
if (c == null) {
LOG.warn("Unknown color: " + quote(cdesc));
LOG.warn("Unknown color: {}", quote(cdesc));
}
return c;
}

Loading…
Cancel
Save