Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Logback 1.1 support and add legacy tests #122

Merged
merged 2 commits into from
Feb 23, 2021
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
17 changes: 17 additions & 0 deletions logback-ecs-encoder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@
<parent.base.dir>${project.basedir}/..</parent.base.dir>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,14 @@ public void init(OutputStream os) {
/**
* This method has been removed in logback 1.2.
* To make this lib backwards compatible with logback 1.1 we have implement this method.
* However, since we compile with 1.2.x, this method is not compiled as an interface method, which means that there won't be type
* erasure. Therefore, we must use a {@link Object} argument for it to be compatible with 1.1.x.
*/
public void doEncode(ILoggingEvent event) throws IOException {
os.write(encode(event));
public void doEncode(Object event) throws IOException {
os.write(encode((ILoggingEvent) event));
// on logback 1.1.x versions this encoder always works as if immediateFlush == true. In later versions, flushing is only handled by
// the appender rather than the encoder
os.flush();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

import java.io.IOException;

class EcsEncoderIntegrationTest extends AbstractEcsEncoderTest {
public class EcsEncoderIntegrationTest extends AbstractEcsEncoderTest {
private OutputStreamAppender appender;

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

import java.io.IOException;

class EcsEncoderTest extends AbstractEcsEncoderTest {
public class EcsEncoderTest extends AbstractEcsEncoderTest {

private OutputStreamAppender appender;

Expand Down
46 changes: 46 additions & 0 deletions logback-legacy-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ecs-logging-java-parent</artifactId>
<groupId>co.elastic.logging</groupId>
<version>1.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>logback-legacy-tests</artifactId>

<properties>
<parent.base.dir>${project.basedir}/..</parent.base.dir>
<maven-deploy-plugin.skip>true</maven-deploy-plugin.skip>
</properties>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>ecs-logging-core</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>logback-ecs-encoder</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>logback-ecs-encoder</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*-
* #%L
* Java ECS logging
* %%
* Copyright (C) 2019 - 2020 Elastic and contributors
* %%
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. 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
*
* http://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.
* #L%
*/
package co.elastic.logging.logback;

class LegacyEcsEncoderIntegrationTest extends EcsEncoderIntegrationTest {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*-
* #%L
* Java ECS logging
* %%
* Copyright (C) 2019 - 2020 Elastic and contributors
* %%
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. 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
*
* http://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.
* #L%
*/
package co.elastic.logging.logback;

class LegacyEcsEncoderTest extends EcsEncoderTest {

}
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<module>jboss-logmanager-ecs-formatter</module>
<module>log4j2-legacy-tests</module>
<module>log4j-legacy-tests</module>
<module>logback-legacy-tests</module>
</modules>
<packaging>pom</packaging>
<inceptionYear>2019</inceptionYear>
Expand Down