Skip to content

Commit

Permalink
Merge branch 'main' into deps/1.25.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhee17 committed Aug 8, 2023
2 parents 1c525e2 + ce5b42f commit 610f483
Show file tree
Hide file tree
Showing 7 changed files with 206 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5154,7 +5154,6 @@ musica.bo
musician.io
mutsu.aomori.jp
mutsuzawa.chiba.jp
mutual
mutual.ar
mv
mw
Expand Down
7 changes: 7 additions & 0 deletions dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ kotlin = "1.9.0"
kotlin-coroutine = "1.7.3"
ktlint-gradle-plugin = "11.5.0"
logback12 = "1.2.11"
logback13 = "1.3.8"
logback14 = "1.4.8"
micrometer = "1.11.2"
micrometer13 = "1.3.20"
Expand Down Expand Up @@ -746,6 +747,12 @@ version.ref = "kotlin-coroutine"
module = "ch.qos.logback:logback-classic"
version.ref = "logback12"
javadocs = "https://www.javadoc.io/doc/ch.qos.logback/logback-classic/1.2.12/"

[libraries.logback13]
module = "ch.qos.logback:logback-classic"
version.ref = "logback13"
javadocs = "https://www.javadoc.io/doc/ch.qos.logback/logback-classic/1.3.8/"

[libraries.logback14]
module = "ch.qos.logback:logback-classic"
version.ref = "logback14"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public long getTimeStamp() {
return event.getTimeStamp();
}

// To keep compatibility with logback 1.4.x
// This method was introduced in logback 1.3.x
// @Override
public Instant getInstant() {
return Instant.ofEpochMilli(event.getTimeStamp());
Expand Down
14 changes: 14 additions & 0 deletions logback13/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
dependencies {
api libs.logback13
}


// Copy common files from logback.
task generateSources(type: Copy) {
from "${rootProject.projectDir}/logback/src/main/java"
into "${project.ext.genSrcDir}/main/java"
exclude "**/LoggingEventWrapper.java"
exclude "**/package-info.java"
}

tasks.compileJava.dependsOn(generateSources)
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/*
* Copyright 2022 LINE Corporation
*
* LINE Corporation licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package com.linecorp.armeria.common.logback;

import java.time.Instant;
import java.util.List;
import java.util.Map;

import org.slf4j.Marker;
import org.slf4j.event.KeyValuePair;

import com.linecorp.armeria.common.annotation.Nullable;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.IThrowableProxy;
import ch.qos.logback.classic.spi.LoggerContextVO;
import ch.qos.logback.classic.spi.LoggingEvent;

// TODO(ikhoon): Use `ILoggingEvent` instead of `LoggingEvent` once https://github.com/qos-ch/logback/pull/614 is merged.
final class LoggingEventWrapper extends LoggingEvent {
private final ILoggingEvent event;
private final Map<String, String> mdcPropertyMap;
@Nullable
private final LoggerContextVO vo;

LoggingEventWrapper(ILoggingEvent event, Map<String, String> mdcPropertyMap) {
this.event = event;
this.mdcPropertyMap = mdcPropertyMap;

final LoggerContextVO oldVo = event.getLoggerContextVO();
if (oldVo != null) {
vo = new LoggerContextVO(oldVo.getName(), mdcPropertyMap, oldVo.getBirthTime());
} else {
vo = null;
}
}

@Override
public Object[] getArgumentArray() {
return event.getArgumentArray();
}

@Override
public Level getLevel() {
return event.getLevel();
}

@Override
public String getLoggerName() {
return event.getLoggerName();
}

@Override
public String getThreadName() {
return event.getThreadName();
}

@Override
public IThrowableProxy getThrowableProxy() {
return event.getThrowableProxy();
}

@Override
public void prepareForDeferredProcessing() {
event.prepareForDeferredProcessing();
}

@Override
@Nullable
public LoggerContextVO getLoggerContextVO() {
return vo;
}

@Override
public String getMessage() {
return event.getMessage();
}

@Override
public long getTimeStamp() {
return event.getTimeStamp();
}

@Override
public Instant getInstant() {
return event.getInstant();
}

@Override
public long getSequenceNumber() {
return event.getSequenceNumber();
}

@Override
public StackTraceElement[] getCallerData() {
return event.getCallerData();
}

@Override
public boolean hasCallerData() {
return event.hasCallerData();
}

@Override
public Marker getMarker() {
return event.getMarker();
}

@Override
public List<Marker> getMarkerList() {
return event.getMarkerList();
}

@Override
public String getFormattedMessage() {
return event.getFormattedMessage();
}

@Override
public Map<String, String> getMDCPropertyMap() {
return mdcPropertyMap;
}

/**
* A synonym for {@link #getMDCPropertyMap}.
* @deprecated Use {@link #getMDCPropertyMap()}.
*/
@Override
@Deprecated
public Map<String, String> getMdc() {
return event.getMDCPropertyMap();
}

@Override
public List<KeyValuePair> getKeyValuePairs() {
return event.getKeyValuePairs();
}

@Override
public String toString() {
return event.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2023 LINE Corporation
*
* LINE Corporation licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

/**
* <a href="https://logback.qos.ch/">Logback</a> integration.
*
* <p>Read '<a href="https://armeria.dev/docs/server-basics">Logging contextual information</a>'
* for more information.
*/
@NonNullByDefault
package com.linecorp.armeria.common.logback;

import com.linecorp.armeria.common.annotation.NonNullByDefault;
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ includeWithFlags ':junit5', 'java', 'publish', 'rel
includeWithFlags ':kafka', 'java', 'publish', 'relocate'
includeWithFlags ':kotlin', 'java', 'publish', 'relocate', 'kotlin'
includeWithFlags ':logback', 'java', 'publish', 'relocate'
includeWithFlags ':logback13', 'java', 'publish', 'relocate', 'no_aggregation'
includeWithFlags ':oauth2', 'java', 'publish', 'relocate'
includeWithFlags ':protobuf', 'java', 'publish', 'relocate'
includeWithFlags ':reactor3', 'java', 'publish', 'relocate'
Expand Down

0 comments on commit 610f483

Please sign in to comment.