Merge branch 'modzeleg' into developer
This commit is contained in:
@@ -5,8 +5,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.release11.klaus.model.Event;
|
||||
import com.release11.klaus.utilis.BusinessKey;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.codehaus.jettison.json.JSONException;
|
||||
import org.codehaus.jettison.json.JSONObject;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
@@ -20,6 +18,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.release11.klaus.utilis.RedisAppender.LOG_PREFIX;
|
||||
|
||||
/**
|
||||
* Builds Event list based on logs created via {@link com.release11.klaus.utilis.TrackingClient} and {@link com.release11.klaus.utilis.RedisAppender}
|
||||
* @author Rafał Żukowicz
|
||||
@@ -27,8 +27,6 @@ import java.util.stream.Collectors;
|
||||
@Repository
|
||||
@AllArgsConstructor
|
||||
public class EventRepositoryImpl implements EventRepository {
|
||||
//TODO: create one constant for both Impl and well as RedisAppender
|
||||
private final String LOG_PREFIX = "logstash_";
|
||||
private final JedisPool jedisPool;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user