-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re #118: Initial stab at log4j/reload4j appender.
- Loading branch information
Showing
17 changed files
with
1,281 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>pl.tkowalcz.tjahzi</groupId> | ||
<artifactId>tjahzi-parent</artifactId> | ||
<version>0.9.33-SNAPSHOT</version> | ||
</parent> | ||
|
||
<name>reload4j-appender</name> | ||
<artifactId>reload4j-appender</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>pl.tkowalcz.tjahzi</groupId> | ||
<artifactId>core</artifactId> | ||
<version>0.9.33-SNAPSHOT</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>ch.qos.reload4j</groupId> | ||
<artifactId>reload4j</artifactId> | ||
<version>1.2.25</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.dropwizard.metrics</groupId> | ||
<artifactId>metrics-core</artifactId> | ||
<version>4.1.17</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- Test dependencies --> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-reload4j</artifactId> | ||
<version>2.0.7</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<version>3.9.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.google.code.java-allocation-instrumenter</groupId> | ||
<artifactId>java-allocation-instrumenter</artifactId> | ||
<version>3.3.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.rest-assured</groupId> | ||
<artifactId>rest-assured</artifactId> | ||
<version>4.3.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.awaitility</groupId> | ||
<artifactId>awaitility</artifactId> | ||
<version>4.0.3</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<version>3.15.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- Testcontainers --> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<version>5.6.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-params</artifactId> | ||
<version>5.6.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<version>5.6.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>testcontainers</artifactId> | ||
<version>1.14.3</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<version>1.14.3</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>nginx</artifactId> | ||
<version>1.14.3</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>dns-cache-manipulator</artifactId> | ||
<version>1.8.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<profiles> | ||
<profile> | ||
<id>allocation-profiling</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<argLine> | ||
-javaagent:"${settings.localRepository}/com/google/code/java-allocation-instrumenter/java-allocation-instrumenter/3.3.0/java-allocation-instrumenter-3.3.0.jar" | ||
</argLine> | ||
</configuration> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.google.code.java-allocation-instrumenter</groupId> | ||
<artifactId>java-allocation-instrumenter</artifactId> | ||
<version>3.3.0</version> | ||
</dependency> | ||
</dependencies> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
42 changes: 42 additions & 0 deletions
42
reload4j-appender/src/main/java/pl/tkowalcz/tjahzi/reload4j/CommaDelimitedListParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package pl.tkowalcz.tjahzi.reload4j; | ||
|
||
import org.apache.log4j.helpers.LogLog; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.function.BiFunction; | ||
|
||
public class CommaDelimitedListParser { | ||
|
||
public static <T> List<T> parseString( | ||
String commaDelimitedList, | ||
BiFunction<String, String, T> converter) { | ||
if (commaDelimitedList == null || commaDelimitedList.trim().isEmpty()) { | ||
return Collections.emptyList(); | ||
} | ||
|
||
ArrayList<T> result = new ArrayList<>(); | ||
String[] keyValuePairs = commaDelimitedList.split(","); | ||
for (String keyValuePair : keyValuePairs) { | ||
String[] keyAndValue = keyValuePair.split(":", 2); | ||
|
||
if (keyAndValue.length != 2) { | ||
LogLog.warn("Invalid key-value pair format: " + keyValuePair); | ||
continue; | ||
} | ||
|
||
String key = keyAndValue[0].trim(); | ||
String value = keyAndValue[1].trim(); | ||
|
||
if (key.isEmpty() || value.isEmpty()) { | ||
LogLog.warn("Key or value cannot be empty: " + keyValuePair); | ||
continue; | ||
} | ||
|
||
result.add(converter.apply(key, value)); | ||
} | ||
|
||
return result; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
reload4j-appender/src/main/java/pl/tkowalcz/tjahzi/reload4j/Header.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package pl.tkowalcz.tjahzi.reload4j; | ||
|
||
public class Header { | ||
|
||
private String name; | ||
private String value; | ||
|
||
public Header(String name, String value) { | ||
this.name = name; | ||
this.value = value; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(String value) { | ||
this.value = value; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
reload4j-appender/src/main/java/pl/tkowalcz/tjahzi/reload4j/Label.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package pl.tkowalcz.tjahzi.reload4j; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
public class Label { | ||
|
||
private static final Pattern LABEL_NAME_PATTER = Pattern.compile("[a-zA-Z_][a-zA-Z0-9_]*"); | ||
|
||
private String name; | ||
private String value; | ||
|
||
public static Label createLabel(String name, String value) { | ||
Label result = new Label(); | ||
result.setName(name); | ||
result.setValue(value); | ||
|
||
return result; | ||
} | ||
|
||
public boolean hasValidName() { | ||
return hasValidName(getName()); | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(String value) { | ||
this.value = value; | ||
} | ||
|
||
public static boolean hasValidName(String label) { | ||
return LABEL_NAME_PATTER.matcher(label).matches(); | ||
} | ||
} |
Oops, something went wrong.