Skip to content

Commit

Permalink
PDFBOX-5695: switch to log4j as suggested by Axel Howind
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1913377 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
lehmi committed Oct 27, 2023
1 parent ab47d80 commit d7be592
Show file tree
Hide file tree
Showing 142 changed files with 848 additions and 825 deletions.
5 changes: 5 additions & 0 deletions pdfbox/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@
<artifactId>jai-imageio-jpeg2000</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.pdfbox.contentstream.operator.MissingOperandException;
import org.apache.pdfbox.contentstream.operator.state.EmptyGraphicsStackException;
import org.apache.pdfbox.cos.COSArray;
Expand Down Expand Up @@ -74,7 +74,7 @@
*/
public abstract class PDFStreamEngine
{
private static final Log LOG = LogFactory.getLog(PDFStreamEngine.class);
private static final Logger LOG = LogManager.getLogger(PDFStreamEngine.class);

private final Map<String, OperatorProcessor> operators = new HashMap<>(80);

Expand Down Expand Up @@ -671,12 +671,12 @@ else if(obj instanceof COSString)
}
else if (obj instanceof COSArray)
{
LOG.error("Nested arrays are not allowed in an array for TJ operation: " + obj);
LOG.error("Nested arrays are not allowed in an array for TJ operation: {}", obj);
}
else
{
LOG.error("Unknown type " + obj.getClass().getSimpleName() +
" in array for TJ operation: " + obj);
LOG.error("Unknown type {} in array for TJ operation: {}",
obj.getClass().getSimpleName(), obj);
}
}
}
Expand Down Expand Up @@ -1045,7 +1045,7 @@ public void setLineDashPattern(COSArray array, int phase)
{
if (phase < 0)
{
LOG.warn("Dash phase has negative value " + phase + ", set to 0");
LOG.warn("Dash phase has negative value {}, set to 0", phase);
phase = 0;
}
PDLineDashPattern lineDash = new PDLineDashPattern(array, phase);
Expand Down Expand Up @@ -1141,7 +1141,7 @@ public void decreaseLevel()
--level;
if (level < 0)
{
LOG.error("level is " + level);
LOG.error("level is {}", level);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import java.io.IOException;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.pdfbox.contentstream.PDFStreamEngine;
import org.apache.pdfbox.cos.COSBase;
import org.apache.pdfbox.cos.COSName;
Expand All @@ -35,7 +35,7 @@
*/
public class DrawObject extends OperatorProcessor
{
private static final Log LOG = LogFactory.getLog(DrawObject.class);
private static final Logger LOG = LogManager.getLogger(DrawObject.class);

public DrawObject(PDFStreamEngine context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import java.io.IOException;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.pdfbox.cos.COSBase;
import org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine;
import org.apache.pdfbox.contentstream.operator.Operator;
Expand All @@ -33,7 +33,7 @@
*/
public final class ClosePath extends GraphicsOperatorProcessor
{
private static final Log LOG = LogFactory.getLog(ClosePath.class);
private static final Logger LOG = LogManager.getLogger(ClosePath.class);

public ClosePath(PDFGraphicsStreamEngine context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import java.io.IOException;
import java.util.List;
import java.awt.geom.Point2D;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine;
import org.apache.pdfbox.contentstream.operator.MissingOperandException;

Expand All @@ -36,7 +36,7 @@
*/
public class CurveTo extends GraphicsOperatorProcessor
{
private static final Log LOG = LogFactory.getLog(CurveTo.class);
private static final Logger LOG = LogManager.getLogger(CurveTo.class);

public CurveTo(PDFGraphicsStreamEngine context)
{
Expand Down Expand Up @@ -68,7 +68,7 @@ public void process(Operator operator, List<COSBase> operands) throws IOExceptio

if (context.getCurrentPoint() == null)
{
LOG.warn("curveTo (" + point3.x + "," + point3.y + ") without initial MoveTo");
LOG.warn("curveTo ({},{}) without initial MoveTo", point3.x, point3.y);
context.moveTo(point3.x, point3.y);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import java.io.IOException;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine;
import org.apache.pdfbox.contentstream.operator.MissingOperandException;
import org.apache.pdfbox.cos.COSBase;
Expand All @@ -36,7 +36,7 @@
*/
public class CurveToReplicateInitialPoint extends GraphicsOperatorProcessor
{
private static final Log LOG = LogFactory.getLog(CurveToReplicateInitialPoint.class);
private static final Logger LOG = LogManager.getLogger(CurveToReplicateInitialPoint.class);

public CurveToReplicateInitialPoint(PDFGraphicsStreamEngine context)
{
Expand Down Expand Up @@ -67,7 +67,7 @@ public void process(Operator operator, List<COSBase> operands) throws IOExceptio

if (currentPoint == null)
{
LOG.warn("curveTo (" + point3.x + "," + point3.y + ") without initial MoveTo");
LOG.warn("curveTo ({},{}) without initial MoveTo", point3.x, point3.y);
context.moveTo(point3.x, point3.y);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import java.io.IOException;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine;
import org.apache.pdfbox.contentstream.operator.MissingOperandException;
import org.apache.pdfbox.cos.COSBase;
Expand All @@ -41,7 +41,7 @@
*/
public final class DrawObject extends GraphicsOperatorProcessor
{
private static final Log LOG = LogFactory.getLog(DrawObject.class);
private static final Logger LOG = LogManager.getLogger(DrawObject.class);

public DrawObject(PDFGraphicsStreamEngine context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import java.util.List;
import java.awt.geom.Point2D;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine;
import org.apache.pdfbox.contentstream.operator.MissingOperandException;
import org.apache.pdfbox.cos.COSBase;
Expand All @@ -36,7 +36,7 @@
*/
public class LineTo extends GraphicsOperatorProcessor
{
private static final Log LOG = LogFactory.getLog(LineTo.class);
private static final Logger LOG = LogManager.getLogger(LineTo.class);

public LineTo(PDFGraphicsStreamEngine context)
{
Expand Down Expand Up @@ -69,7 +69,7 @@ public void process(Operator operator, List<COSBase> operands) throws IOExceptio

if (context.getCurrentPoint() == null)
{
LOG.warn("LineTo (" + pos.x + "," + pos.y + ") without initial MoveTo");
LOG.warn("LineTo ({},{}) without initial MoveTo", pos.x, pos.y);
context.moveTo(pos.x, pos.y);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import java.io.IOException;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.pdfbox.contentstream.PDFStreamEngine;
import org.apache.pdfbox.contentstream.operator.MissingOperandException;
import org.apache.pdfbox.contentstream.operator.Operator;
Expand All @@ -41,7 +41,7 @@
*/
public class DrawObject extends OperatorProcessor
{
private static final Log LOG = LogFactory.getLog(DrawObject.class);
private static final Logger LOG = LogManager.getLogger(DrawObject.class);

public DrawObject(PDFStreamEngine context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import java.io.IOException;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.pdfbox.cos.COSBase;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState;
Expand All @@ -37,7 +37,7 @@
*/
public class SetGraphicsStateParameters extends OperatorProcessor
{
private static final Log LOG = LogFactory.getLog(SetGraphicsStateParameters.class);
private static final Logger LOG = LogManager.getLogger(SetGraphicsStateParameters.class);

public SetGraphicsStateParameters(PDFStreamEngine context)
{
Expand All @@ -63,7 +63,7 @@ public void process(Operator operator, List<COSBase> arguments) throws IOExcepti
PDExtendedGraphicsState gs = context.getResources().getExtGState(graphicsName);
if (gs == null)
{
LOG.error("name for 'gs' operator not found in resources: /" + graphicsName.getName());
LOG.error("name for 'gs' operator not found in resources: /{}", graphicsName.getName());
return;
}
gs.copyIntoGraphicsState( context.getGraphicsState() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.pdfbox.contentstream.PDFStreamEngine;
import org.apache.pdfbox.contentstream.operator.MissingOperandException;
import org.apache.pdfbox.contentstream.operator.Operator;
Expand All @@ -36,7 +36,7 @@
*/
public class SetLineDashPattern extends OperatorProcessor
{
private static final Log LOG = LogFactory.getLog(SetLineDashPattern.class);
private static final Logger LOG = LogManager.getLogger(SetLineDashPattern.class);

public SetLineDashPattern(PDFStreamEngine context)
{
Expand Down Expand Up @@ -75,7 +75,7 @@ public void process(Operator operator, List<COSBase> arguments) throws MissingOp
}
else
{
LOG.warn("dash array has non number element " + base + ", ignored");
LOG.warn("dash array has non number element {}, ignored", base);
dashArray = new COSArray();
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.pdfbox.contentstream.PDFStreamEngine;
import org.apache.pdfbox.contentstream.operator.MissingOperandException;
import org.apache.pdfbox.contentstream.operator.Operator;
Expand All @@ -36,7 +36,7 @@
*/
public class MoveText extends OperatorProcessor
{
private static final Log LOG = LogFactory.getLog(MoveText.class);
private static final Logger LOG = LogManager.getLogger(MoveText.class);

public MoveText(PDFStreamEngine context)
{
Expand All @@ -54,7 +54,7 @@ public void process(Operator operator, List<COSBase> arguments) throws MissingOp
Matrix textLineMatrix = context.getTextLineMatrix();
if (textLineMatrix == null)
{
LOG.warn("TextLineMatrix is null, " + getName() + " operator will be ignored");
LOG.warn("TextLineMatrix is null, {} operator will be ignored", getName());
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.pdfbox.contentstream.PDFStreamEngine;
import org.apache.pdfbox.contentstream.operator.MissingOperandException;
import org.apache.pdfbox.contentstream.operator.Operator;
Expand All @@ -40,7 +40,7 @@
*/
public class SetFontAndSize extends OperatorProcessor
{
private static final Log LOG = LogFactory.getLog(SetFontAndSize.class);
private static final Logger LOG = LogManager.getLogger(SetFontAndSize.class);

public SetFontAndSize(PDFStreamEngine context)
{
Expand Down Expand Up @@ -72,7 +72,7 @@ public void process(Operator operator, List<COSBase> arguments) throws IOExcepti
PDFont font = context.getResources().getFont(fontName);
if (font == null)
{
LOG.warn("font '" + fontName.getName() + "' not found in resources");
LOG.warn("font '{}' not found in resources", fontName.getName());
}
context.getGraphicsState().getTextState().setFont(font);
}
Expand Down
6 changes: 3 additions & 3 deletions pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import java.util.Set;
import java.util.function.BiConsumer;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;

import org.apache.pdfbox.pdmodel.common.COSObjectable;
import org.apache.pdfbox.util.DateConverter;
Expand All @@ -48,7 +48,7 @@ public class COSDictionary extends COSBase implements COSUpdateInfo
/**
* Log instance.
*/
private static final Log LOG = LogFactory.getLog(COSDictionary.class);
private static final Logger LOG = LogManager.getLogger(COSDictionary.class);

private static final String PATH_SEPARATOR = "/";
private static final int MAP_THRESHOLD = 1000;
Expand Down
6 changes: 3 additions & 3 deletions pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import java.util.Map.Entry;
import java.util.stream.Collectors;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.pdfbox.io.IOUtils;
import org.apache.pdfbox.io.RandomAccessStreamCache;
import org.apache.pdfbox.io.RandomAccessStreamCache.StreamCacheCreateFunction;
Expand All @@ -44,7 +44,7 @@ public class COSDocument extends COSBase implements Closeable
/**
* Log instance.
*/
private static final Log LOG = LogFactory.getLog(COSDocument.class);
private static final Logger LOG = LogManager.getLogger(COSDocument.class);

private float version = 1.4f;

Expand Down
Loading

0 comments on commit d7be592

Please sign in to comment.