Skip to content

Commit

Permalink
revert Configurator interface to match that in version 1.4.8
Browse files Browse the repository at this point in the history
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
  • Loading branch information
ceki committed Aug 9, 2023
1 parent 70071fe commit 4633df5
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ public class BasicConfigurator extends ContextAwareBase implements Configurator
public BasicConfigurator() {
}

public ExecutionStatus configure(Context context) {
public ExecutionStatus configure(LoggerContext loggerContext) {
addInfo("Setting up default configuration.");

LoggerContext loggerContext = (LoggerContext) context;

ConsoleAppender<ILoggingEvent> ca = new ConsoleAppender<ILoggingEvent>();
ca.setContext(context);
ca.setName("console");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package ch.qos.logback.classic.joran;

import ch.qos.logback.classic.ClassicConstants;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.serializedModel.HardenedModelInputStream;
import ch.qos.logback.classic.model.processor.LogbackClassicDefaultNestedComponentRules;
import ch.qos.logback.classic.spi.ConfiguratorRank;
Expand Down Expand Up @@ -53,7 +54,7 @@ public class SerializedModelConfigurator extends ContextAwareBase implements Con
protected ModelInterpretationContext modelInterpretationContext;

@Override
public ExecutionStatus configure(Context context) {
public ExecutionStatus configure(LoggerContext loggerContext) {

URL url = performMultiStepModelFileSearch(true);
if (url != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package ch.qos.logback.classic.spi;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.Context;
import ch.qos.logback.core.spi.ContextAware;

Expand All @@ -24,24 +25,25 @@
/**
* Allows programmatic initialization and configuration of Logback. The
* ServiceLoader is typically used to instantiate implementations and thus
* implementations will need to follow the guidelines of the ServiceLoader
* specifically a no-arg constructor is required.
* implementations will need to follow the guidelines of the ServiceLoader,
* in particular the no-arg constructor requirement.
*
* The return type of {@link #configure(Context) configure} was changed from 'void' to
* The return type of {@link #configure(LoggerContext) configure} was changed from 'void' to
* {@link ExecutionStatus) in logback version 1.3.0.
*/
public interface Configurator extends ContextAware {

enum ExecutionStatus {
NEUTRAL, // let the caller decide
INVOKE_NEXT_IF_ANY, // invoke other
DO_NOT_INVOKE_NEXT_IF_ANY
DO_NOT_INVOKE_NEXT_IF_ANY // the caller should not invoke further configurators even some are available
}

/**
* The context will also be set before this method is called via
* {@link ContextAware#setContext(ch.qos.logback.core.Context)}.
* Implementations of this method may expect that the {@link LoggerContext} is set with
* {@link ContextAware#setContext} before this method is invoked.
*
*/
ExecutionStatus configure(Context context);
ExecutionStatus configure(LoggerContext context);

}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private Configurator instantiateConfiguratorByClassName(String configuratorClass
/**
*
* @param configurator
* @return true if enclosing loop should break, false otherwise
* @return ExecutionStatus
*/
private Configurator.ExecutionStatus invokeConfigure(Configurator configurator) {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ch.qos.logback.classic.util;

import ch.qos.logback.classic.ClassicConstants;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.classic.spi.ConfiguratorRank;
import ch.qos.logback.core.Context;
Expand All @@ -27,7 +28,7 @@
public class DefaultJoranConfigurator extends ContextAwareBase implements Configurator {

@Override
public ExecutionStatus configure(Context context) {
public ExecutionStatus configure(LoggerContext context) {
URL url = performMultiStepConfigurationFileSearch(true);
if (url != null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package ch.qos.logback.classic.util;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.Configurator;
import ch.qos.logback.classic.spi.ConfiguratorRank;
import ch.qos.logback.core.Context;
Expand All @@ -23,7 +24,7 @@ public class MockConfigurator extends ContextAwareBase implements Configurator {

static Context context = null;

public ExecutionStatus configure(Context aContext) {
public ExecutionStatus configure(LoggerContext aContext) {
context = aContext;
return ExecutionStatus.NEUTRAL;
}
Expand Down

0 comments on commit 4633df5

Please sign in to comment.