Skip to content

Commit

Permalink
Cleanup (#1)
Browse files Browse the repository at this point in the history
* 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
StrongestNumber9 authored Jun 15, 2023
1 parent f5cb5e7 commit 256facf
Show file tree
Hide file tree
Showing 43 changed files with 1,461 additions and 3,896 deletions.
12 changes: 0 additions & 12 deletions .github/dependabot.yml

This file was deleted.

51 changes: 51 additions & 0 deletions .github/workflows/upload_release.yaml
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 }}
15 changes: 0 additions & 15 deletions .gitignore
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
110 changes: 0 additions & 110 deletions .mvn/wrapper/MavenWrapperDownloader.java

This file was deleted.

18 changes: 0 additions & 18 deletions .mvn/wrapper/maven-wrapper.properties

This file was deleted.

10 changes: 0 additions & 10 deletions Jenkinsfile

This file was deleted.

96 changes: 96 additions & 0 deletions README.adoc
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();
----
Loading

0 comments on commit 256facf

Please sign in to comment.