Skip to content

Commit

Permalink
add IRelpAppenderConfig.java (#37)
Browse files Browse the repository at this point in the history
* add IRelpAppenderConfig.java

* add license to IRelpAppenderConfig.java

* change license year in IRelpAppenderConfig.java

* change license year in RlpLogbackAppender.java
  • Loading branch information
kortemik authored Nov 25, 2024
1 parent 73d9ca9 commit c5b5b10
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 2 deletions.
63 changes: 63 additions & 0 deletions src/main/java/com/teragrep/jla_01/IRelpAppenderConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
Reliable Event Logging Protocol (RELP) Logback plugin
Copyright (C) 2021-2024 Suomen Kanuuna Oy
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.
*/
package com.teragrep.jla_01;

import ch.qos.logback.core.encoder.LayoutWrappingEncoder;
import com.teragrep.rlp_01.RelpConnection;

/**
* Bean interface that reflects settings in logback.xml
* @param <E>
*/
public interface IRelpAppenderConfig<E> {
void setEncoder(LayoutWrappingEncoder encoder);

void setSender(RelpConnection sender);

void setRelpPort(int relpPort);

void setEnableEventId48577(Boolean enableEventId48577);

void setRelpHostAddress(String relpHostAddress);

void setAppName(String appName);

void setHostname(String hostname);

// set connectionTimeout in seconds
void setConnectionTimeout(int timeout);

void setWriteTimeout(int timeout);

void setReadTimeout(int timeout);

//set reconnectInterval in milliseconds
void setReconnectInterval(int interval);

void setKeepAlive(boolean on);

void setReconnectIfNoMessagesInterval(int interval);

// tls
void setUseTLS(boolean on);

void setKeystorePath(String keystorePath);

void setKeystorePassword(String keystorePassword);

void setTlsProtocol(String tlsProtocol);
}
21 changes: 19 additions & 2 deletions src/main/java/com/teragrep/jla_01/RlpLogbackAppender.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Reliable Event Logging Protocol (RELP) Logback plugin
Copyright (C) 2021 Suomen Kanuuna Oy
Copyright (C) 2021-2024 Suomen Kanuuna Oy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,7 +36,7 @@ Reliable Event Logging Protocol (RELP) Logback plugin
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;

public class RlpLogbackAppender<E> extends AppenderBase<E> {
public class RlpLogbackAppender<E> extends AppenderBase<E> implements IRelpAppenderConfig<E> {

// see also https://stackoverflow.com/questions/31415899/correct-way-to-stop-custom-logback-async-appender

Expand Down Expand Up @@ -71,81 +71,98 @@ public class RlpLogbackAppender<E> extends AppenderBase<E> {
private String tlsProtocol = "";


@Override
public void setEncoder(LayoutWrappingEncoder encoder) {
this.encoder = encoder;
}

@Override
public void setSender(RelpConnection sender) {
this.sender = sender;
}

@Override
public void setRelpPort(int relpPort) {
this.relpPort = relpPort;
}

@Override
public void setEnableEventId48577(Boolean enableEventId48577) {
this.enableEventId48577 = enableEventId48577;
}

@Override
public void setRelpHostAddress(String relpHostAddress) {
this.relpHostAddress = relpHostAddress;
}

@Override
public void setAppName(String appName) {
this.appName = appName;
}

@Override
public void setHostname(String hostname) {
this.hostname = hostname;
}

// set connectionTimeout in seconds
@Override
public void setConnectionTimeout(int timeout) {
if (timeout > 0) {
this.connectionTimeout = timeout;
}
}

@Override
public void setWriteTimeout(int timeout) {
if (timeout > 0) {
this.writeTimeout = timeout;
}
}

@Override
public void setReadTimeout(int timeout) {
if (timeout > 0) {
this.readTimeout = timeout;
}
}

//set reconnectInterval in milliseconds
@Override
public void setReconnectInterval(int interval) {
if (interval > 0) {
this.reconnectInterval = interval;
}
}

@Override
public void setKeepAlive(boolean on) {
this.keepAlive=on;
}

@Override
public void setReconnectIfNoMessagesInterval(int interval) {
this.reconnectIfNoMessagesInterval = interval;
}

// tls
@Override
public void setUseTLS(boolean on) {
this.useTLS = on;
}

@Override
public void setKeystorePath(String keystorePath) {
this.keystorePath = keystorePath;
}

@Override
public void setKeystorePassword(String keystorePassword) {
this.keystorePassword = keystorePassword;
}

@Override
public void setTlsProtocol(String tlsProtocol) {
this.tlsProtocol = tlsProtocol;
}
Expand Down

0 comments on commit c5b5b10

Please sign in to comment.