-
-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This merges in the most recent changes from logback that were tagged with "v_1.0.12".
- Loading branch information
Showing
279 changed files
with
12,433 additions
and
2,519 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
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
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
81 changes: 81 additions & 0 deletions
81
logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ReceiverAction.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,81 @@ | ||
/** | ||
* Logback: the reliable, generic, fast and flexible logging framework. | ||
* Copyright (C) 1999-2013, 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 org.xml.sax.Attributes; | ||
|
||
import ch.qos.logback.classic.net.ReceiverBase; | ||
import ch.qos.logback.classic.net.SocketReceiver; | ||
import ch.qos.logback.core.joran.action.Action; | ||
import ch.qos.logback.core.joran.spi.ActionException; | ||
import ch.qos.logback.core.joran.spi.InterpretationContext; | ||
import ch.qos.logback.core.util.OptionHelper; | ||
|
||
/** | ||
* A Joran {@link Action} for a {@link SocketReceiver} configuration. | ||
* | ||
* @author Carl Harris | ||
*/ | ||
public class ReceiverAction extends Action { | ||
|
||
private ReceiverBase receiver; | ||
private boolean inError; | ||
|
||
@Override | ||
public void begin(InterpretationContext ic, String name, | ||
Attributes attributes) throws ActionException { | ||
|
||
String className = attributes.getValue(CLASS_ATTRIBUTE); | ||
if (OptionHelper.isEmpty(className)) { | ||
addError("Missing class name for receiver. Near [" + name | ||
+ "] line " + getLineNumber(ic)); | ||
inError = true; | ||
return; | ||
} | ||
|
||
try { | ||
addInfo("About to instantiate receiver of type [" + className + "]"); | ||
|
||
receiver = (ReceiverBase) OptionHelper.instantiateByClassName( | ||
className, ReceiverBase.class, context); | ||
receiver.setContext(context); | ||
|
||
ic.pushObject(receiver); | ||
} | ||
catch (Exception ex) { | ||
inError = true; | ||
addError("Could not create a receiver of type [" + className + "].", ex); | ||
throw new ActionException(ex); | ||
} | ||
} | ||
|
||
@Override | ||
public void end(InterpretationContext ic, String name) | ||
throws ActionException { | ||
|
||
if (inError) return; | ||
|
||
ic.getContext().register(receiver); | ||
receiver.start(); | ||
|
||
Object o = ic.peekObject(); | ||
if (o != receiver) { | ||
addWarn("The object at the of the stack is not the remote " + | ||
"pushed earlier."); | ||
} else { | ||
ic.popObject(); | ||
} | ||
} | ||
|
||
} |
87 changes: 87 additions & 0 deletions
87
logback-classic/src/main/java/ch/qos/logback/classic/net/ReceiverBase.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,87 @@ | ||
/** | ||
* Logback: the reliable, generic, fast and flexible logging framework. | ||
* Copyright (C) 1999-2013, 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.net; | ||
|
||
import ch.qos.logback.core.spi.ContextAwareBase; | ||
import ch.qos.logback.core.spi.LifeCycle; | ||
|
||
/** | ||
* An abstract base for components that receive logging events from a remote | ||
* peer and log according to local policy | ||
* | ||
* @author Carl Harris | ||
*/ | ||
public abstract class ReceiverBase extends ContextAwareBase | ||
implements LifeCycle { | ||
|
||
private boolean started; | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public final void start() { | ||
if (isStarted()) return; | ||
if (getContext() == null) { | ||
throw new IllegalStateException("context not set"); | ||
} | ||
if (shouldStart()) { | ||
getContext().getExecutorService().execute(getRunnableTask()); | ||
started = true; | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public final void stop() { | ||
if (!isStarted()) return; | ||
try { | ||
onStop(); | ||
} | ||
catch (RuntimeException ex) { | ||
addError("on stop: " + ex, ex); | ||
} | ||
started = false; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public final boolean isStarted() { | ||
return started; | ||
} | ||
|
||
/** | ||
* Determines whether this receiver should start. | ||
* <p> | ||
* Subclasses will implement this method to do any subclass-specific | ||
* validation. The subclass's {@link #getRunnableTask()} method will be | ||
* invoked (and the task returned will be submitted to the executor) | ||
* if and only if this method returns {@code true} | ||
* @return flag indicating whether this receiver should start | ||
*/ | ||
protected abstract boolean shouldStart(); | ||
|
||
/** | ||
* Allows a subclass to participate in receiver shutdown. | ||
*/ | ||
protected abstract void onStop(); | ||
|
||
/** | ||
* Provides the runnable task this receiver will execute. | ||
* @return runnable task | ||
*/ | ||
protected abstract Runnable getRunnableTask(); | ||
|
||
} |
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.