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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
java-version: '11'

- name: Build with Gradle
run: ./gradlew build
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2025 EPAM Systems
# Licensed 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.

name: Publish to Maven Central

on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., 5.4.1)'
required: true
type: string

jobs:
publish:
uses: reportportal/.github/.github/workflows/maven-publish.yml@main
with:
version: ${{ github.event.inputs.version }}
artifact: logger-java-logback
package_suffixes: '-javadoc.jar,-javadoc.jar.asc,-javadoc.jar.md5,-javadoc.jar.sha1,-javadoc.jar.sha256,-javadoc.jar.sha512,-sources.jar,-sources.jar.asc,-sources.jar.md5,-sources.jar.sha1,-sources.jar.sha256,-sources.jar.sha512,.jar,.jar.asc,.jar.md5,.jar.sha1,.jar.sha256,.jar.sha512,.pom,.pom.asc,.pom.md5,.pom.sha1,.pom.sha256,.pom.sha512,.module,.module.asc,.module.md5,.module.sha1,.module.sha256,.module.sha512'
secrets:
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
111 changes: 0 additions & 111 deletions .github/workflows/promote.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
java-version: '11'

- name: Setup git credentials
uses: oleksiyrudenko/gha-git-credentials@v2-latest
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog

## [Unreleased]
### Changed
- Client version updated to [5.4.1](https://github.com/reportportal/client-java/releases/tag/5.4.1), by @HardNorth
- Logback version updated to 1.5.18, by @HardNorth
- Switch on use of `Instant` class instead of `Date` to get more timestamp precision, by @HardNorth
### Removed
- Java 8, 9, 10 support, by @HardNorth

## [5.3.0]
### Changed
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ project.ext.limits = [
'class' : 90
]

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

repositories {
mavenCentral()
Expand All @@ -42,7 +42,7 @@ dependencies {

testImplementation "com.epam.reportportal:client-java:${client_version}"
testImplementation "ch.qos.logback:logback-classic:${logback_version}"
testImplementation 'com.epam.reportportal:agent-java-test-utils:0.0.12'
testImplementation 'com.epam.reportportal:agent-java-test-utils:0.1.0'
testImplementation('org.awaitility:awaitility:4.0.2') {
exclude group: 'org.hamcrest'
}
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version=5.3.1-SNAPSHOT
version=5.4.0-SNAPSHOT
description=EPAM Report portal. Logback Integration
scripts_url=https://raw.githubusercontent.com/reportportal/gradle-scripts
scripts_branch=master
client_version=5.3.14
logback_version=1.3.15
client_version=5.4.1
logback_version=1.5.18
junit_version=5.6.3
junit_runner_version=1.6.3
mockito_version=3.3.3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
/*
* Copyright (C) 2019 EPAM Systems
* Copyright 2025 EPAM Systems
*
* Licensed 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
* 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.epam.reportportal.logback.appender;

import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
Expand All @@ -24,8 +25,8 @@
import com.epam.reportportal.message.TypeAwareByteSource;
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ;

import java.time.Instant;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.UUID;

Expand All @@ -36,67 +37,66 @@
*/
public class ReportPortalAppender extends AppenderBase<ILoggingEvent> {

private static final MessageParser MESSAGE_PARSER = new HashMarkSeparatedMessageParser();
private static final List<String> LOGGING_ISSUE =
Collections.singletonList("com.epam.reportportal.service.logs.LoggingSubscriber");
private PatternLayoutEncoder encoder;
private static final MessageParser MESSAGE_PARSER = new HashMarkSeparatedMessageParser();
private static final List<String> LOGGING_ISSUE = Collections.singletonList("com.epam.reportportal.service.logs.LoggingSubscriber");
private PatternLayoutEncoder encoder;

@Override
protected void append(final ILoggingEvent event) {
String loggerName = event.getLoggerName();
for (String packagePrefix : LOGGING_ISSUE) {
if (loggerName.startsWith(packagePrefix)) {
return;
}
}
@Override
protected void append(final ILoggingEvent event) {
String loggerName = event.getLoggerName();
for (String packagePrefix : LOGGING_ISSUE) {
if (loggerName.startsWith(packagePrefix)) {
return;
}
}

emitLog(itemUuid -> {
final String message = event.getFormattedMessage();
final String level = event.getLevel().toString();
final Date time = new Date(event.getTimeStamp());
emitLog(itemUuid -> {
final String message = event.getFormattedMessage();
final String level = event.getLevel().toString();
final Instant time = event.getInstant();

SaveLogRQ request = new SaveLogRQ();
request.setLevel(level);
request.setLogTime(time);
request.setItemUuid(itemUuid);
SaveLogRQ request = new SaveLogRQ();
request.setLevel(level);
request.setLogTime(time);
request.setItemUuid(itemUuid);

try {
if (MESSAGE_PARSER.supports(message)) {
ReportPortalMessage rpMessage = MESSAGE_PARSER.parse(message);
TypeAwareByteSource data = rpMessage.getData();
SaveLogRQ.File file = new SaveLogRQ.File();
file.setContent(data.read());
file.setContentType(data.getMediaType());
file.setName(UUID.randomUUID().toString());
try {
if (MESSAGE_PARSER.supports(message)) {
ReportPortalMessage rpMessage = MESSAGE_PARSER.parse(message);
TypeAwareByteSource data = rpMessage.getData();
SaveLogRQ.File file = new SaveLogRQ.File();
file.setContent(data.read());
file.setContentType(data.getMediaType());
file.setName(UUID.randomUUID().toString());

request.setFile(file);
request.setMessage(rpMessage.getMessage());
} else {
request.setMessage(encoder.getLayout().doLayout(event));
}
} catch (Exception e) {
//skip
}
return request;
});
}
request.setFile(file);
request.setMessage(rpMessage.getMessage());
} else {
request.setMessage(encoder.getLayout().doLayout(event));
}
} catch (Exception e) {
//skip
}
return request;
});
}

@Override
public void start() {
if (this.encoder == null) {
addError("No encoder set for the appender named [" + name + "].");
return;
}
this.encoder.start();
super.start();
}
@Override
public void start() {
if (this.encoder == null) {
addError("No encoder set for the appender named [" + name + "].");
return;
}
this.encoder.start();
super.start();
}

@SuppressWarnings("unused")
public PatternLayoutEncoder getEncoder() {
return encoder;
}
@SuppressWarnings("unused")
public PatternLayoutEncoder getEncoder() {
return encoder;
}

public void setEncoder(PatternLayoutEncoder encoder) {
this.encoder = encoder;
}
public void setEncoder(PatternLayoutEncoder encoder) {
this.encoder = encoder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void test_logger_append() {
logger.info("test message");
launch.finishTestItem(id, new FinishTestItemRQ());
launch.finish(new FinishExecutionRQ());
verify(client).log(any(List.class));
verify(client, times(2)).log(any(List.class));
}

@Test
Expand All @@ -124,7 +124,7 @@ public void test_logger_skip() {
Logger logger = createLoggerFor(LoggingSubscriber.class);
launch.finishTestItem(id, new FinishTestItemRQ());
launch.finish(new FinishExecutionRQ());
verify(client, timeout(100).times(0)).log(any(List.class));
verify(client, timeout(100).times(1)).log(any(List.class));
}

@Test
Expand All @@ -143,9 +143,9 @@ public void test_binary_file_message_encoding() throws IOException {
launch.finish(new FinishExecutionRQ());

ArgumentCaptor<List<MultipartBody.Part>> captor = ArgumentCaptor.forClass(List.class);
verify(client).log(captor.capture());
verify(client, times(2)).log(captor.capture());

List<MultipartBody.Part> request = captor.getValue();
List<MultipartBody.Part> request = captor.getAllValues().get(0);
assertThat(request, hasSize(2));

RequestBody jsonPart = request.get(0).body();
Expand Down