-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
further progress on PropertyConfigurator
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
- Loading branch information
Showing
15 changed files
with
498 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...classic/src/main/java/ch/qos/logback/classic/joran/action/PropertyConfiguratorAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Logback: the reliable, generic, fast and flexible logging framework. | ||
* Copyright (C) 1999-2024, QOS.ch. All rights reserved. | ||
* | ||
* This program and the accompanying materials are dual-licensed under | ||
* either the terms of the Eclipse Public License v1.0 as published by | ||
* the Eclipse Foundation | ||
* | ||
* or (per the licensee's choosing) | ||
* | ||
* under the terms of the GNU Lesser General Public License version 2.1 | ||
* as published by the Free Software Foundation. | ||
*/ | ||
|
||
package ch.qos.logback.classic.joran.action; | ||
|
||
import ch.qos.logback.classic.model.PropertyConfiguratorModel; | ||
import ch.qos.logback.core.joran.action.ResourceAction; | ||
import ch.qos.logback.core.model.IncludeModel; | ||
|
||
/** | ||
* Build an {@link PropertyConfiguratorModel} instance from SAX events. | ||
* | ||
* @author Ceki Gülcü | ||
* @since 1.5.8 | ||
*/ | ||
public class PropertyConfiguratorAction extends ResourceAction { | ||
|
||
protected PropertyConfiguratorModel makeNewResourceModel() { | ||
return new PropertyConfiguratorModel(); | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
logback-classic/src/main/java/ch/qos/logback/classic/model/PropertyConfiguratorModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Logback: the reliable, generic, fast and flexible logging framework. | ||
* Copyright (C) 1999-2024, QOS.ch. All rights reserved. | ||
* | ||
* This program and the accompanying materials are dual-licensed under | ||
* either the terms of the Eclipse Public License v1.0 as published by | ||
* the Eclipse Foundation | ||
* | ||
* or (per the licensee's choosing) | ||
* | ||
* under the terms of the GNU Lesser General Public License version 2.1 | ||
* as published by the Free Software Foundation. | ||
*/ | ||
|
||
package ch.qos.logback.classic.model; | ||
|
||
import ch.qos.logback.core.model.ResourceModel; | ||
|
||
public class PropertyConfiguratorModel extends ResourceModel { | ||
|
||
private static final long serialVersionUID = -2009536798661734346L; | ||
} |
83 changes: 83 additions & 0 deletions
83
...rc/main/java/ch/qos/logback/classic/model/processor/PropertyConfiguratorModelHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Logback: the reliable, generic, fast and flexible logging framework. | ||
* Copyright (C) 1999-2024, QOS.ch. All rights reserved. | ||
* | ||
* This program and the accompanying materials are dual-licensed under | ||
* either the terms of the Eclipse Public License v1.0 as published by | ||
* the Eclipse Foundation | ||
* | ||
* or (per the licensee's choosing) | ||
* | ||
* under the terms of the GNU Lesser General Public License version 2.1 | ||
* as published by the Free Software Foundation. | ||
*/ | ||
|
||
package ch.qos.logback.classic.model.processor; | ||
|
||
import ch.qos.logback.classic.joran.PropertyConfigurator; | ||
import ch.qos.logback.classic.model.PropertyConfiguratorModel; | ||
import ch.qos.logback.core.Context; | ||
import ch.qos.logback.core.joran.spi.JoranException; | ||
import ch.qos.logback.core.joran.util.ConfigurationWatchListUtil; | ||
import ch.qos.logback.core.model.IncludeModel; | ||
import ch.qos.logback.core.model.Model; | ||
import ch.qos.logback.core.model.ResourceModel; | ||
import ch.qos.logback.core.model.processor.ModelHandlerException; | ||
import ch.qos.logback.core.model.processor.ModelInterpretationContext; | ||
import ch.qos.logback.core.model.processor.ResourceHandlerBase; | ||
import ch.qos.logback.core.util.OptionHelper; | ||
|
||
import java.io.InputStream; | ||
import java.net.URL; | ||
|
||
public class PropertyConfiguratorModelHandler extends ResourceHandlerBase { | ||
boolean inError = false; | ||
|
||
public PropertyConfiguratorModelHandler(Context context) { | ||
super(context); | ||
} | ||
|
||
static public PropertyConfiguratorModelHandler makeInstance(Context context, ModelInterpretationContext mic) { | ||
return new PropertyConfiguratorModelHandler(context); | ||
} | ||
|
||
@Override | ||
public void handle(ModelInterpretationContext mic, Model model) throws ModelHandlerException { | ||
PropertyConfiguratorModel propertyConfiguratorModel = (PropertyConfiguratorModel) model; | ||
|
||
this.optional = OptionHelper.toBoolean(propertyConfiguratorModel.getOptional(), false); | ||
|
||
if (!checkAttributes(propertyConfiguratorModel)) { | ||
inError = true; | ||
return; | ||
} | ||
|
||
InputStream in = getInputStream(mic, propertyConfiguratorModel); | ||
if(in == null) { | ||
inError = true; | ||
return; | ||
} | ||
|
||
addInfo("Reading configuration from ["+getAttribureInUse()+"]"); | ||
|
||
PropertyConfigurator propertyConfigurator = new PropertyConfigurator(); | ||
propertyConfigurator.setContext(mic.getContext()); | ||
try { | ||
propertyConfigurator.doConfigure(in); | ||
} catch (JoranException e) { | ||
addError("Could not configure from "+getAttribureInUse()); | ||
throw new ModelHandlerException(e); | ||
} | ||
|
||
} | ||
|
||
protected InputStream getInputStream(ModelInterpretationContext mic, ResourceModel resourceModel) { | ||
URL inputURL = getInputURL(mic, resourceModel); | ||
if (inputURL == null) | ||
return null; | ||
|
||
ConfigurationWatchListUtil.addToWatchList(context, inputURL); | ||
return openURL(inputURL); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
logback-classic/src/test/input/joran/propertyConfigurator/smoke.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# | ||
# Logback: the reliable, generic, fast and flexible logging framework. | ||
# Copyright (C) 1999-2024, QOS.ch. All rights reserved. | ||
# | ||
# This program and the accompanying materials are dual-licensed under | ||
# either the terms of the Eclipse Public License v1.0 as published by | ||
# the Eclipse Foundation | ||
# | ||
# or (per the licensee's choosing) | ||
# | ||
# under the terms of the GNU Lesser General Public License version 2.1 | ||
# as published by the Free Software Foundation. | ||
# | ||
|
||
logback.logger.com.toto = WARN |
30 changes: 30 additions & 0 deletions
30
logback-classic/src/test/input/joran/propertyConfigurator/smoke.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!-- | ||
~ Logback: the reliable, generic, fast and flexible logging framework. | ||
~ Copyright (C) 1999-2024, QOS.ch. All rights reserved. | ||
~ | ||
~ This program and the accompanying materials are dual-licensed under | ||
~ either the terms of the Eclipse Public License v1.0 as published by | ||
~ the Eclipse Foundation | ||
~ | ||
~ or (per the licensee's choosing) | ||
~ | ||
~ under the terms of the GNU Lesser General Public License version 2.1 | ||
~ as published by the Free Software Foundation. | ||
--> | ||
|
||
<configuration> | ||
|
||
<appender name="LIST" class="ch.qos.logback.core.testUtil.StringListAppender"> | ||
<layout class="ch.qos.logback.classic.PatternLayout"> | ||
<Pattern>%msg</Pattern> | ||
</layout> | ||
</appender> | ||
|
||
<variable name="JO_PREFIX" value="src/test/input/joran" /> | ||
|
||
<propertyConfigurator file="${JO_PREFIX}/propertyConfigurator/smoke.properties" /> | ||
|
||
<root level="debug"> | ||
<appender-ref ref="LIST" /> | ||
</root> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.