Skip to content

Commit 5dc7d9f

Browse files
authored
Merge pull request #12 from newrelic/custom-connection-logContext
feat: Added logging context
2 parents 33a5e9f + ce9f148 commit 5dc7d9f

14 files changed

+798
-800
lines changed

custom-log4j2-appender/build-jar.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jar {
2020
'Implementation-Title': 'Custom Log4j2 Appender',
2121
'Implementation-Vendor': 'New Relic Labs',
2222
'Implementation-Vendor-Id': 'com.newrelic.labs',
23-
'Implementation-Version': '1.0.6'
23+
'Implementation-Version': '1.1.2'
2424
)
2525
}
2626
}
@@ -53,7 +53,7 @@ publishing {
5353

5454
groupId = 'com.newrelic.labs'
5555
artifactId = 'custom-log4j2-appender'
56-
version = '1.0.6'
56+
version = '1.1.2'
5757

5858
pom {
5959
name = 'Custom Log4j2 Appender'

custom-log4j2-appender/build-shadowJar.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ shadowJar {
2727
'Implementation-Title': 'Custom Log4j2 Appender',
2828
'Implementation-Vendor': 'New Relic Labs',
2929
'Implementation-Vendor-Id': 'com.newrelic.labs',
30-
'Implementation-Version': '1.0.6'
30+
'Implementation-Version': '1.1.2'
3131
)
3232
}
3333
}
@@ -55,7 +55,7 @@ publishing {
5555

5656
groupId = 'com.newrelic.labs'
5757
artifactId = 'custom-log4j2-appender'
58-
version = '1.0.6'
58+
version = '1.1.2'
5959

6060
pom {
6161
name = 'Custom Log4j2 Appender'

custom-log4j2-appender/build.gradle

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
plugins {
22
id 'java'
3-
id 'com.github.johnrengelman.shadow' version '6.1.0'
43
id 'maven-publish'
54
}
65

@@ -16,22 +15,18 @@ dependencies {
1615
}
1716

1817
jar {
19-
enabled = false // Disable the standard JAR task
20-
}
21-
22-
shadowJar {
23-
archiveClassifier.set('') // Remove the 'all' classifier
24-
mergeServiceFiles()
2518
manifest {
2619
attributes(
2720
'Implementation-Title': 'Custom Log4j2 Appender',
2821
'Implementation-Vendor': 'New Relic Labs',
2922
'Implementation-Vendor-Id': 'com.newrelic.labs',
30-
'Implementation-Version': '1.0.6'
23+
'Implementation-Version': '1.1.2'
3124
)
3225
}
3326
}
3427

28+
29+
3530
tasks.withType(JavaCompile) {
3631
options.encoding = 'UTF-8'
3732
}
@@ -46,16 +41,19 @@ task sourcesJar(type: Jar) {
4641
from sourceSets.main.allSource
4742
}
4843

44+
45+
4946
publishing {
5047
publications {
5148
mavenJava(MavenPublication) {
52-
artifact shadowJar // Only include Shadow JAR
49+
from components.java // Include standard JAR
50+
5351
artifact javadocJar
5452
artifact sourcesJar
5553

5654
groupId = 'com.newrelic.labs'
5755
artifactId = 'custom-log4j2-appender'
58-
version = '1.0.6'
56+
version = '1.1.2'
5957

6058
pom {
6159
name = 'Custom Log4j2 Appender'

custom-log4j2-appender/publish-jar-legacy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cp build-jar.gradle build.gradle
77
# Set variables
88
GROUP_ID="com.newrelic.labs"
99
ARTIFACT_ID="custom-log4j2-appender"
10-
VERSION="1.0.6"
10+
VERSION="1.1.2"
1111
KEY_ID="0ED9FD74E81E6D83FAE25F235640EA0B1C631C6F" # Replace with your actual key ID
1212

1313
# Get the current directory (assuming the script is run from the custom-log4j2-appender directory)

custom-log4j2-appender/publish-jar.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cp build-jar.gradle build.gradle
77
# Set variables
88
GROUP_ID="io.github.newrelic-experimental"
99
ARTIFACT_ID="custom-log4j2-appender"
10-
VERSION="1.0.6"
10+
VERSION="1.1.2"
1111
KEY_ID="0ED9FD74E81E6D83FAE25F235640EA0B1C631C6F" # Replace with your actual key ID
1212

1313
# Get the current directory (assuming the script is run from the custom-log4j2-appender directory)

custom-log4j2-appender/publish-shadowJar.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cp build-shadowJar.gradle build.gradle
66
# Set variables
77
GROUP_ID="io.github.newrelic-experimental"
88
ARTIFACT_ID="custom-log4j2-appender"
9-
VERSION="1.0.6"
9+
VERSION="1.1.2"
1010
KEY_ID="0ED9FD74E81E6D83FAE25F235640EA0B1C631C6F" # Replace with your actual key ID
1111

1212
# Get the current directory (assuming the script is run from the custom-log4j2-appender directory)

custom-log4j2-appender/src/main/java/com/newrelic/labs/FlushCallback.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import java.util.Map;
55

66
public interface FlushCallback {
7-
void onSuccess();
7+
void onSuccess();
88

9-
void onFailure(List<Map<String, Object>> failedLogEvents);
9+
void onFailure(List<Map<String, Object>> failedLogEvents);
1010
}

custom-log4j2-appender/src/main/java/com/newrelic/labs/LogEntry.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ public class LogEntry {
1313
private final String name;
1414
private final String logtype;
1515
private final long timestamp;
16+
private final Map<String, Object> properties; // Add custom fields
1617

1718
public LogEntry(String message, String applicationName, String name, String logtype, long timestamp,
18-
Map<String, Object> custom, boolean mergeCustomFields) {
19+
Map<String, Object> properties, boolean mergeCustomFields) {
1920
this.message = message;
2021
this.applicationName = applicationName;
2122
this.name = name;
2223
this.logtype = logtype;
2324
this.timestamp = timestamp;
24-
25+
this.properties = properties; // Initialize custom fields
2526
}
2627

2728
// Default constructor for Jackson
@@ -31,17 +32,20 @@ public LogEntry() {
3132
this.name = null;
3233
this.logtype = null;
3334
this.timestamp = 0L;
35+
this.properties = null; // Initialize custom fields
3436
}
3537

3638
@JsonCreator
3739
public LogEntry(@JsonProperty("message") String message, @JsonProperty("applicationname") String applicationName,
3840
@JsonProperty("name") String name, @JsonProperty("logtype") String logtype,
39-
@JsonProperty("timestamp") long timestamp) {
41+
@JsonProperty("timestamp") long timestamp, @JsonProperty("custom") Map<String, Object> properties) { // Add
42+
4043
this.message = message;
4144
this.applicationName = applicationName;
4245
this.name = name;
4346
this.logtype = logtype;
4447
this.timestamp = timestamp;
48+
this.properties = properties; // Initialize custom fields
4549
}
4650

4751
public String getMessage() {
@@ -63,4 +67,8 @@ public String getLogType() {
6367
public long getTimestamp() {
6468
return timestamp;
6569
}
66-
}
70+
71+
public Map<String, Object> getProperties() { // Add getter for custom
72+
return properties;
73+
}
74+
}

0 commit comments

Comments
 (0)