forked from jenkinsci/syslog-java-client
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Major cleanup * Update readme, to adoc * Remove MessageFormat * Fixes copypaste mistake * Optimize writing sd params, use stringbuilder where possible * Fixes getTimestamp * Fixes readme, developer info * Fixes license on BenchmarkTest * Adds copyright to pom * Fixes legacy double conversion * Do not support date anymore, use Instant for timestamps, rewrite format test * Another hashset to linkedhashset * README fixes * Use java benchmarking harness * Add copyright, author headers on modified files * Adds github workflow * Adds tests for SD and missing fields, fixes boundaries to align with rfc5424 specs
- Loading branch information
1 parent
f5cb5e7
commit 256facf
Showing
43 changed files
with
1,461 additions
and
3,896 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,51 @@ | ||
name: Upload Release | ||
|
||
on: | ||
release: | ||
types: published | ||
|
||
jobs: | ||
upload: | ||
name: Upload | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Cache Local Maven Repository | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
|
||
- name: Setup Maven Central | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: 8.0.292+10 | ||
distribution: 'adopt' | ||
|
||
server-id: ossrh | ||
server-username: MAVEN_CENTRAL_USERNAME | ||
server-password: MAVEN_CENTRAL_TOKEN | ||
|
||
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | ||
gpg-passphrase: MAVEN_GPG_PASSPHRASE | ||
|
||
- name: Publish to Maven Central | ||
run: mvn --batch-mode -Drevision=${{ github.event.release.tag_name }} -Dsha1= -Dchangelist= clean deploy -Ppublish-maven-central | ||
env: | ||
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} | ||
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }} | ||
|
||
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | ||
|
||
- name: Setup GitHub Packages | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: 8.0.292+10 | ||
distribution: 'adopt' | ||
|
||
- name: Publish to GitHub Packages | ||
run: mvn --batch-mode -Drevision=${{ github.event.release.tag_name }} -Dsha1= -Dchangelist= clean deploy -Ppublish-github-packages | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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 |
---|---|---|
@@ -1,21 +1,6 @@ | ||
target/ | ||
pom.xml.tag | ||
pom.xml.releaseBackup | ||
pom.xml.versionsBackup | ||
pom.xml.next | ||
release.properties | ||
dependency-reduced-pom.xml | ||
buildNumber.properties | ||
.mvn/timing.properties | ||
.mvn/wrapper/maven-wrapper.jar | ||
|
||
# IntelliJ IDEA project files | ||
*.iml | ||
*.iws | ||
*.ipr | ||
.idea | ||
|
||
# Eclipse project files | ||
.settings | ||
.classpath | ||
.project |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,96 @@ | ||
= Java RFC5424 Syslog Formatter | ||
|
||
== Description | ||
|
||
Java RFC5424 formatter library | ||
|
||
== Using the Syslog Java Client with Maven | ||
|
||
Add the following dependency in your pom.xml: | ||
|
||
[source,xml] | ||
---- | ||
<dependency> | ||
<groupId>com.teragrep</groupId> | ||
<artifactId>rlo_14</artifactId> | ||
<version>1.0.0</version> | ||
</dependency> | ||
---- | ||
|
||
== Usage | ||
|
||
Sourcing timestamp from long | ||
[source,java] | ||
---- | ||
Instant time = Instant.now(); | ||
SyslogMessage message = new SyslogMessage() | ||
.withTimestamp(time.toEpochMilli()) | ||
.withAppName("my_app") | ||
.withHostname("localhost") | ||
.withFacility(Facility.USER) | ||
.withSeverity(Severity.INFORMATIONAL) | ||
.withMsg("a syslog message"); | ||
String actual = message.toRfc5424SyslogMessage(); | ||
---- | ||
|
||
Sourcing timestamp from Instant | ||
[source,java] | ||
---- | ||
Instant time = Instant.now(); | ||
SyslogMessage message = new SyslogMessage() | ||
.withTimestamp(time) | ||
.withAppName("my_app") | ||
.withHostname("localhost") | ||
.withFacility(Facility.USER) | ||
.withSeverity(Severity.INFORMATIONAL) | ||
.withMsg("a syslog message"); | ||
String actual = message.toRfc5424SyslogMessage(); | ||
---- | ||
|
||
Sourcing timestamp from string (parsed and validated) | ||
[source,java] | ||
---- | ||
SyslogMessage message = new SyslogMessage() | ||
.withTimestamp("2023-06-14T16:37:00.000Z") | ||
.withAppName("my_app") | ||
.withHostname("localhost") | ||
.withFacility(Facility.USER) | ||
.withSeverity(Severity.INFORMATIONAL) | ||
.withMsg("a syslog message"); | ||
String actual = message.toRfc5424SyslogMessage(); | ||
---- | ||
|
||
Sourcing timestamp from string (no validation, useful when you know you have correct format) | ||
[source,java] | ||
---- | ||
SyslogMessage message = new SyslogMessage() | ||
.withTimestamp("2023-06-14T16:37:00.000Z", true) | ||
.withAppName("my_app") | ||
.withHostname("localhost") | ||
.withFacility(Facility.USER) | ||
.withSeverity(Severity.INFORMATIONAL) | ||
.withMsg("a syslog message"); | ||
String actual = message.toRfc5424SyslogMessage(); | ||
---- | ||
|
||
Adding structured data | ||
|
||
[source,java] | ||
---- | ||
SyslogMessage message = new SyslogMessage() | ||
.withTimestamp("2023-06-14T16:37:00.000Z") | ||
.withAppName("my_app") | ||
.withHostname("localhost") | ||
.withFacility(Facility.USER) | ||
.withSeverity(Severity.INFORMATIONAL) | ||
.withMsg("a syslog message") | ||
.withSDElement( | ||
new SDElement( | ||
"event_version@48577", | ||
new SDParam("major", "1"), | ||
new SDParam("minor", "0"), | ||
new SDParam("version_source", "source") | ||
) | ||
); | ||
String actual = message.toRfc5424SyslogMessage(); | ||
---- |
Oops, something went wrong.