Skip to content

Commit

Permalink
Merge tag 'tags/v_1.0.12'
Browse files Browse the repository at this point in the history
This merges in the most recent changes from logback that were tagged with "v_1.0.12".
  • Loading branch information
tony19 committed Feb 2, 2014
1 parent 5428f5d commit 2b6d303
Show file tree
Hide file tree
Showing 279 changed files with 12,433 additions and 2,519 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ target
*.ipr
*.iws
logback-classic/jdbc:hsqldb:mem:test.log
logback-classic/jdbc:hsqldb:mem:test.properties
logback-classic/jdbc:hsqldb:mem:test.properties
logback-classic/jdbc:hsqldb:mem:test.script
2 changes: 1 addition & 1 deletion logback-classic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.github.tony19</groupId>
<artifactId>logback-android-parent</artifactId>
<version>1.0.11-1-SNAPSHOT</version>
<version>1.0.12-1-SNAPSHOT</version>
</parent>

<artifactId>logback-android-classic</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ public class ClassicConstants {
*/
public static final int DEFAULT_MAX_CALLEDER_DATA_DEPTH = 8;

public static final Marker FINALIZE_SESSION_MARKER = MarkerFactory.getMarker("FINALIZE_SESSION");
public static final String FINALIZE_SESSION = "FINALIZE_SESSION";
public static final Marker FINALIZE_SESSION_MARKER = MarkerFactory.getMarker(FINALIZE_SESSION);
}
34 changes: 9 additions & 25 deletions logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.slf4j.spi.LocationAwareLogger;

import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.LoggerRemoteView;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.CoreConstants;
Expand All @@ -37,10 +36,7 @@
public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
AppenderAttachable<ILoggingEvent>, Serializable {

/**
*
*/
private static final long serialVersionUID = 5454405123156820674L;
private static final long serialVersionUID = 5454405123156820674L; //8745934908040027998L;

/**
* The fully qualified name of this class. Used in gathering caller
Expand All @@ -55,22 +51,22 @@ public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
private String name;

// The assigned levelInt of this logger. Can be null.
private Level level;
transient private Level level;

// The effective levelInt is the assigned levelInt and if null, a levelInt is
// inherited form a parent.
private int effectiveLevelInt;
transient private int effectiveLevelInt;

/**
* The parent of this category. All categories have at least one ancestor
* which is the root category.
*/
private Logger parent;
transient private Logger parent;

/**
* The children of this logger. A logger may have zero or more children.
*/
private List<Logger> childrenList;
transient private List<Logger> childrenList;

/**
* It is assumed that once the 'aai' variable is set to a non-null value, it
Expand All @@ -92,7 +88,7 @@ public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
* <p>
* 4) AppenderAttachableImpl is thread safe
*/
private transient AppenderAttachableImpl<ILoggingEvent> aai;
transient private AppenderAttachableImpl<ILoggingEvent> aai;
/**
* Additivity is set to true by default, that is children inherit the
* appenders of their ancestors by default. If this variable is set to
Expand All @@ -101,18 +97,14 @@ public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
* its appenders, unless the children have their additivity flag set to
* <code>false</code> too. See the user manual for more details.
*/
private boolean additive = true;
transient private boolean additive = true;

final transient LoggerContext loggerContext;
// loggerRemoteView cannot be final because it may change as a consequence
// of changes in LoggerContext
LoggerRemoteView loggerRemoteView;

Logger(String name, Logger parent, LoggerContext loggerContext) {
this.name = name;
this.parent = parent;
this.loggerContext = loggerContext;
buildRemoteView();
}

public Level getEffectiveLevel() {
Expand Down Expand Up @@ -789,14 +781,6 @@ public LoggerContext getLoggerContext() {
return loggerContext;
}

public LoggerRemoteView getLoggerRemoteView() {
return loggerRemoteView;
}

void buildRemoteView() {
this.loggerRemoteView = new LoggerRemoteView(name, loggerContext);
}

public void log(Marker marker, String fqcn, int levelInt, String message,
Object[] argArray, Throwable t) {
Level level = Level.fromLocationAwareLoggerInteger(levelInt);
Expand All @@ -805,8 +789,8 @@ public void log(Marker marker, String fqcn, int levelInt, String message,

/**
* After serialization, the logger instance does not know its LoggerContext.
* The best we can do here, is to return a logger with the same name as
* generated by LoggerFactory.
* The best we can do here, is to return a logger with the same name
* returned by org.slf4j.LoggerFactory.
*
* @return Logger instance with the same name
* @throws ObjectStreamException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,8 @@ void initEvaluatorMap() {
* A new instance of LoggerContextRemoteView needs to be created each time the
* name or propertyMap (including keys or values) changes.
*/
private void syncRemoteView() {
private void updateLoggerContextVO() {
loggerContextRemoteView = new LoggerContextVO(this);
for (Logger logger : loggerCache.values()) {
logger.buildRemoteView();
}
}

private boolean isSpecialKey(String key) {
Expand Down Expand Up @@ -124,13 +121,13 @@ public String getProperty(String key) {
@Override
public void putProperty(String key, String val) {
super.putProperty(key, val);
syncRemoteView();
updateLoggerContextVO();
}

@Override
public void setName(String name) {
super.setName(name);
syncRemoteView();
updateLoggerContextVO();
}

public final Logger getLogger(final Class clazz) {
Expand Down Expand Up @@ -268,7 +265,7 @@ public void addTurboFilter(TurboFilter newFilter) {
}

/**
* First stop all registered turbo filters and then clear the registration
* First processPriorToRemoval all registered turbo filters and then clear the registration
* list.
*/
public void resetTurboFilterList() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public void addInstanceRules(RuleStore rs) {

rs.addRule(new Pattern("configuration/includes"), new FindIncludeAction());
rs.addRule(new Pattern("configuration/includes/include"), new ConditionalIncludeAction());

rs.addRule(new Pattern("configuration/receiver"),
new ReceiverAction());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected SaxEventRecorder createRecorder(InputStream in, URL url) {
rec.setFilter("logback");
recorder = rec;
} else {
recorder = new SaxEventRecorder();
recorder = new SaxEventRecorder(getContext());
}
return recorder;
}
Expand Down
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();
}
}

}
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();

}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected void fillBuffer(CyclicBuffer<ILoggingEvent> cb, StringBuffer sbuf) {
}
}

protected boolean isEventMarkedForBufferRemoval(ILoggingEvent eventObject) {
protected boolean eventMarksEndOfLife(ILoggingEvent eventObject) {
Marker marker = eventObject.getMarker();
if(marker == null)
return false;
Expand Down
Loading

0 comments on commit 2b6d303

Please sign in to comment.