Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .claude/skills/architecture-sync/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: architecture-sync
description: Read this WHEN A CHANGE ALTERS THE SHAPE OF THE LIBRARY — adding, removing, renaming or moving a Java package under logback-android/src/main/java; moving a responsibility between packages; adding an android.* import to a new package or any core→classic import; adding a published output (artifact, flavor, the XSD, consumer R8 rules) or a runtime dependency; or changing how configuration is discovered or a log call is dispatched. Also read it before opening the PR for such a change, and when asked to check whether docs/architecture is still accurate.
description: Read this WHEN A CHANGE ALTERS THE SHAPE OF THE LIBRARY — adding, removing, renaming or moving a Java or Kotlin package under logback-android/src/main/java or src/main/kotlin; moving a responsibility between packages; adding an android.* import to a new package or any core→classic import; adding a published output (artifact, flavor, the XSD, consumer R8 rules) or a runtime dependency; or changing how configuration is discovered or a log call is dispatched. Also read it before opening the PR for such a change, and when asked to check whether docs/architecture is still accurate.
---

# Keeping the architecture docs true
Expand Down Expand Up @@ -44,7 +44,7 @@ is a design question, not a documentation question — ask before writing it dow
```

Add, remove or rename the entry to match. The backticked directory path (relative to
`logback-android/src/main/java`) is what the gate matches on, so it has to be exact. Mark
`logback-android/src/main/java` or `logback-android/src/main/kotlin`) is what the gate matches on, so it has to be exact. Mark
Android-only packages as such.

Then read the entries **either side of the change**, not just the one you added. A
Expand Down
7 changes: 4 additions & 3 deletions docs/architecture/components.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Component catalogue

One entry per Java package under `logback-android/src/main/java`. The heading's backticked
One entry per package under `logback-android/src/main/java` (the upstream logback port) or
`logback-android/src/main/kotlin` (the Android layer, #388). The heading's backticked
path is what `scripts/check-architecture-docs.sh` matches on, so it must be exact. Each entry
says what the package is responsible for, and anything that must stay true of it.

Expand Down Expand Up @@ -29,7 +30,7 @@ safety of `Logger` and `LoggerContext` is load-bearing: they are called from eve

### `ch/qos/logback/classic/android` — `ch.qos.logback.classic.android`

Android-only appenders: `LogcatAppender`, `SQLiteAppender` (+ `SQLiteLogCleaner`), and
Kotlin. Android-only appenders: `LogcatAppender`, `SQLiteAppender` (+ `SQLiteLogCleaner`), and
`BasicLogcatConfigurator`, which an app calls to log to logcat without a `logback.xml`. One of the few
packages allowed to import `android.*`.

Expand Down Expand Up @@ -133,7 +134,7 @@ the locking model of every appender built on them.

### `ch/qos/logback/core/android` — `ch.qos.logback.core.android`

Android-only: `AndroidContextUtil` (resolves `DATA_DIR`, `EXT_DIR`, package name, etc. for
Kotlin. Android-only: `AndroidContextUtil` (resolves `DATA_DIR`, `EXT_DIR`, package name, etc. for
configuration properties) and `SystemPropertiesProxy`. Lookups are lazy so configuration does
not read disk on the main thread (see #383).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ public class AsyncAppender extends AsyncAppenderBase<ILoggingEvent> {
* @param event
* @return true if the event is of level TRACE, DEBUG or INFO false otherwise.
*/
@Override
protected boolean isDiscardable(ILoggingEvent event) {
Level level = event.getLevel();
return level.toInt() <= Level.INFO_INT;
}

@Override
protected void preprocess(ILoggingEvent eventObject) {
eventObject.prepareForDeferredProcessing();
if(includeCallerData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class BasicConfigurator extends ContextAwareBase implements Configurator
public BasicConfigurator() {
}

@Override
public void configure(LoggerContext lc) {
addInfo("Setting up default configuration.");
ConsoleAppender<ILoggingEvent> ca = new ConsoleAppender<ILoggingEvent>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ private Level(int levelInt, String levelStr) {
* Returns the string representation of this Level.
* @return the string value of this level
*/
@Override
public String toString() {
return levelStr;
}
Expand Down
41 changes: 40 additions & 1 deletion logback-android/src/main/java/ch/qos/logback/classic/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
private String name;

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

// The effective levelInt is the assigned levelInt and if null, a levelInt is
// inherited form a parent.
Expand Down Expand Up @@ -122,6 +122,7 @@ public Level getLevel() {
return level;
}

@Override
public String getName() {
return name;
}
Expand Down Expand Up @@ -207,12 +208,14 @@ private synchronized void handleParentLevelChange(int newParentLevelInt) {
* <p>
* This is useful when re-reading configuration information.
*/
@Override
public void detachAndStopAllAppenders() {
if (aai != null) {
aai.detachAndStopAllAppenders();
}
}

@Override
public boolean detachAppender(String name) {
if (aai == null) {
return false;
Expand All @@ -222,13 +225,15 @@ public boolean detachAppender(String name) {

// this method MUST be synchronized. See comments on 'aai' field for further
// details.
@Override
public synchronized void addAppender(Appender<ILoggingEvent> newAppender) {
if (aai == null) {
aai = new AppenderAttachableImpl<ILoggingEvent>();
}
aai.addAppender(newAppender);
}

@Override
public boolean isAttached(Appender<ILoggingEvent> appender) {
if (aai == null) {
return false;
Expand All @@ -237,13 +242,15 @@ public boolean isAttached(Appender<ILoggingEvent> appender) {
}

@SuppressWarnings("unchecked")
@Override
public Iterator<Appender<ILoggingEvent>> iteratorForAppenders() {
if (aai == null) {
return Collections.EMPTY_LIST.iterator();
}
return aai.iteratorForAppenders();
}

@Override
public Appender<ILoggingEvent> getAppender(String name) {
if (aai == null) {
return null;
Expand Down Expand Up @@ -282,6 +289,7 @@ private int appendLoopOnAppenders(ILoggingEvent event) {
/**
* Remove the appender passed as parameter form the list of appenders.
*/
@Override
public boolean detachAppender(Appender<ILoggingEvent> appender) {
if (aai == null) {
return false;
Expand Down Expand Up @@ -439,22 +447,27 @@ private void buildLoggingEventAndAppend(final String localFQCN,
callAppenders(le);
}

@Override
public void trace(String msg) {
filterAndLog_0_Or3Plus(FQCN, null, Level.TRACE, msg, null, null);
}

@Override
public void trace(String format, Object arg) {
filterAndLog_1(FQCN, null, Level.TRACE, format, arg, null);
}

@Override
public void trace(String format, Object arg1, Object arg2) {
filterAndLog_2(FQCN, null, Level.TRACE, format, arg1, arg2, null);
}

@Override
public void trace(String format, Object... argArray) {
filterAndLog_0_Or3Plus(FQCN, null, Level.TRACE, format, argArray, null);
}

@Override
public void trace(String msg, Throwable t) {
filterAndLog_0_Or3Plus(FQCN, null, Level.TRACE, msg, null, t);
}
Expand Down Expand Up @@ -509,6 +522,7 @@ public void trace(List<Marker> markers, String msg, Throwable t) {
filterAndLog_0_Or3Plus(FQCN, markers, Level.TRACE, msg, null, t);
}

@Override
public boolean isDebugEnabled() {
return isDebugEnabled(Collections.<Marker>emptyList());
}
Expand All @@ -526,22 +540,27 @@ public boolean isDebugEnabled(List<Marker> markers) {
}
}

@Override
public void debug(String msg) {
filterAndLog_0_Or3Plus(FQCN, null, Level.DEBUG, msg, null, null);
}

@Override
public void debug(String format, Object arg) {
filterAndLog_1(FQCN, null, Level.DEBUG, format, arg, null);
}

@Override
public void debug(String format, Object arg1, Object arg2) {
filterAndLog_2(FQCN, null, Level.DEBUG, format, arg1, arg2, null);
}

@Override
public void debug(String format, Object... argArray) {
filterAndLog_0_Or3Plus(FQCN, null, Level.DEBUG, format, argArray, null);
}

@Override
public void debug(String msg, Throwable t) {
filterAndLog_0_Or3Plus(FQCN, null, Level.DEBUG, msg, null, t);
}
Expand Down Expand Up @@ -596,22 +615,27 @@ public void debug(List<Marker> markers, String msg, Throwable t) {
filterAndLog_0_Or3Plus(FQCN, markers, Level.DEBUG, msg, null, t);
}

@Override
public void error(String msg) {
filterAndLog_0_Or3Plus(FQCN, null, Level.ERROR, msg, null, null);
}

@Override
public void error(String format, Object arg) {
filterAndLog_1(FQCN, null, Level.ERROR, format, arg, null);
}

@Override
public void error(String format, Object arg1, Object arg2) {
filterAndLog_2(FQCN, null, Level.ERROR, format, arg1, arg2, null);
}

@Override
public void error(String format, Object... argArray) {
filterAndLog_0_Or3Plus(FQCN, null, Level.ERROR, format, argArray, null);
}

@Override
public void error(String msg, Throwable t) {
filterAndLog_0_Or3Plus(FQCN, null, Level.ERROR, msg, null, t);
}
Expand Down Expand Up @@ -666,6 +690,7 @@ public void error(List<Marker> markers, String msg, Throwable t) {
filterAndLog_0_Or3Plus(FQCN, markers, Level.ERROR, msg, null, t);
}

@Override
public boolean isInfoEnabled() {
return isInfoEnabled(Collections.<Marker>emptyList());
}
Expand All @@ -683,22 +708,27 @@ public boolean isInfoEnabled(List<Marker> markers) {
}
}

@Override
public void info(String msg) {
filterAndLog_0_Or3Plus(FQCN, null, Level.INFO, msg, null, null);
}

@Override
public void info(String format, Object arg) {
filterAndLog_1(FQCN, null, Level.INFO, format, arg, null);
}

@Override
public void info(String format, Object arg1, Object arg2) {
filterAndLog_2(FQCN, null, Level.INFO, format, arg1, arg2, null);
}

@Override
public void info(String format, Object... argArray) {
filterAndLog_0_Or3Plus(FQCN, null, Level.INFO, format, argArray, null);
}

@Override
public void info(String msg, Throwable t) {
filterAndLog_0_Or3Plus(FQCN, null, Level.INFO, msg, null, t);
}
Expand Down Expand Up @@ -753,6 +783,7 @@ public void info(List<Marker> markers, String msg, Throwable t) {
filterAndLog_0_Or3Plus(FQCN, markers, Level.INFO, msg, null, t);
}

@Override
public boolean isTraceEnabled() {
return isTraceEnabled(Collections.<Marker>emptyList());
}
Expand All @@ -770,6 +801,7 @@ public boolean isTraceEnabled(List<Marker> markers) {
}
}

@Override
public boolean isErrorEnabled() {
return isErrorEnabled(Collections.<Marker>emptyList());
}
Expand All @@ -787,6 +819,7 @@ public boolean isErrorEnabled(List<Marker> markers) {
}
}

@Override
public boolean isWarnEnabled() {
return isWarnEnabled(Collections.<Marker>emptyList());
}
Expand Down Expand Up @@ -822,10 +855,12 @@ public boolean isEnabledFor(Level level) {
return isEnabledFor(null, level);
}

@Override
public void warn(String msg) {
filterAndLog_0_Or3Plus(FQCN, null, Level.WARN, msg, null, null);
}

@Override
public void warn(String msg, Throwable t) {
filterAndLog_0_Or3Plus(FQCN, null, Level.WARN, msg, null, t);
}
Expand Down Expand Up @@ -860,14 +895,17 @@ public void warn(Marker marker, String msg, Throwable t) {
warn(Collections.singletonList(marker), msg, t);
}

@Override
public void warn(String format, Object arg) {
filterAndLog_1(FQCN, null, Level.WARN, format, arg, null);
}

@Override
public void warn(String format, Object arg1, Object arg2) {
filterAndLog_2(FQCN, null, Level.WARN, format, arg1, arg2, null);
}

@Override
public void warn(String format, Object... argArray) {
filterAndLog_0_Or3Plus(FQCN, null, Level.WARN, format, argArray, null);
}
Expand Down Expand Up @@ -900,6 +938,7 @@ public void setAdditive(boolean additive) {
this.additive = additive;
}

@Override
public String toString() {
return "Logger[" + name + "]";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public final Logger getLogger(final Class<?> clazz) {
return getLogger(clazz.getName());
}

@Override
public Logger getLogger(final String name) {

if (name == null) {
Expand Down Expand Up @@ -350,11 +351,13 @@ private void fireOnStop() {

// === end listeners ==============================================

@Override
public void start() {
super.start();
fireOnStart();
}

@Override
public void stop() {
reset();
fireOnStop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,12 @@ public PatternLayout() {
this.postCompileProcessor = new EnsureExceptionHandling();
}

@Override
public Map<String, String> getDefaultConverterMap() {
return defaultConverterMap;
}

@Override
public String doLayout(ILoggingEvent event) {
if (!isStarted()) {
return CoreConstants.EMPTY_STRING;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class OnErrorEvaluator extends EventEvaluatorBase<ILoggingEvent> {
* Return true if event passed as parameter has level ERROR or higher, returns
* false otherwise.
*/
@Override
public boolean evaluate(ILoggingEvent event) throws NullPointerException,
EvaluationException {
return event.getLevel().levelInt >= Level.ERROR_INT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public void addMarker(String markerStr) {
* Return true if event passed as parameter contains one of the specified
* user-markers.
*/
@Override
public boolean evaluate(ILoggingEvent event) throws NullPointerException,
EvaluationException {

Expand Down
Loading
Loading