Skip to content

Commit

Permalink
PDFBOX-5695: add license header, format code
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1913390 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
lehmi committed Oct 27, 2023
1 parent aefada7 commit d778fc0
Showing 1 changed file with 34 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.pdfbox.debugger.ui;

import org.apache.logging.log4j.*;
Expand All @@ -12,31 +28,38 @@

public class DebugLogAppender extends AbstractAppender
{
protected DebugLogAppender(String name, Filter filter, Layout<? extends Serializable> layout, final boolean ignoreExceptions) {
protected DebugLogAppender(String name, Filter filter, Layout<? extends Serializable> layout,
final boolean ignoreExceptions)
{
super(name, filter, layout, ignoreExceptions);
}

@Override
public void append(LogEvent event) {
public void append(LogEvent event)
{
// forward to your logging dialog box here.
LogDialog.instance().log(event.getLoggerName(), event.getLevel().name(), event.getMessage().getFormattedMessage(), event.getThrown());
LogDialog.instance().log(event.getLoggerName(), event.getLevel().name(),
event.getMessage().getFormattedMessage(), event.getThrown());
}

public static void setupCustomLogger() {
ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder();
public static void setupCustomLogger()
{
ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory
.newConfigurationBuilder();

AppenderComponentBuilder appenderBuilder = builder.newAppender("Stdout", "CONSOLE")
.addAttribute("target", ConsoleAppender.Target.SYSTEM_OUT);
appenderBuilder.add(builder.newLayout("PatternLayout")
.addAttribute("pattern", "%d [%t] %-5level: %msg%n%throwable"));
appenderBuilder.add(builder.newLayout("PatternLayout").addAttribute("pattern",
"%d [%t] %-5level: %msg%n%throwable"));
builder.add(appenderBuilder);

appenderBuilder = builder.newAppender("Custom", "org.package.CustomAppender");
appenderBuilder.add(builder.newLayout("PatternLayout")
.addAttribute("pattern", "%d [%t] %-5level: %msg%n%throwable"));
appenderBuilder.add(builder.newLayout("PatternLayout").addAttribute("pattern",
"%d [%t] %-5level: %msg%n%throwable"));
builder.add(appenderBuilder);

builder.add(builder.newRootLogger(Level.ERROR).add(builder.newAppenderRef("Stdout")).add(builder.newAppenderRef("Custom")));
builder.add(builder.newRootLogger(Level.ERROR).add(builder.newAppenderRef("Stdout"))
.add(builder.newAppenderRef("Custom")));
Configurator.initialize(builder.build());
}
}
}

0 comments on commit d778fc0

Please sign in to comment.