TODO unchecked. Code removed. Constant LOG_PREFIX added.

This commit is contained in:
2021-03-26 17:35:43 +01:00
parent 79d1bd67c3
commit 517dd2a586
4 changed files with 7 additions and 10 deletions

View File

@@ -18,17 +18,13 @@ import redis.clients.jedis.Protocol;
/**
* Class is used to insert logs directly to Redis. {@link com.release11.klaus.repository.EventRepositoryImpl} is using those logs.
* @author Rafał Żukowicz
* @author Gabriel Modzelewski
*/
public class RedisAppender extends UnsynchronizedAppenderBase<ILoggingEvent> {
JedisPool pool;
// keep this for config compatibility for now
JSONEventLayout jsonlayout;
Layout<ILoggingEvent> layout;
// logger configurable options
String host = "localhost";
int port = Protocol.DEFAULT_PORT;
String key = null;
@@ -36,6 +32,9 @@ public class RedisAppender extends UnsynchronizedAppenderBase<ILoggingEvent> {
String password = null;
int database = Protocol.DEFAULT_DATABASE;
public static final String LOG_PREFIX = "logstash_";
public RedisAppender() {
jsonlayout = new JSONEventLayout();
}
@@ -49,7 +48,7 @@ public class RedisAppender extends UnsynchronizedAppenderBase<ILoggingEvent> {
Jedis client = pool.getResource();
try {
String json = layout == null ? jsonlayout.doLayout(event) : layout.doLayout(event);
key = "logstash_" + LocalDate.now();
key = LOG_PREFIX + LocalDate.now();
client.rpush(key, json);
} catch (Exception e) {
e.printStackTrace();