Skip to content

Commit

Permalink
Merge pull request #214 from raynigon/bugfix/access-logs
Browse files Browse the repository at this point in the history
Bugfix/access logs
  • Loading branch information
raynigon committed May 2, 2023
2 parents f1b3b54 + 51440c0 commit 7bbcc28
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
id 'java-library'
id 'signing'
id 'maven-publish'
id 'org.springframework.boot' version '3.0.4'
id 'org.springframework.boot' version '3.0.6'
id 'io.spring.dependency-management' version '1.1.0'

// Auto Update Versions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
import com.raynigon.ecs.logging.access.AccessLogProperties;
import com.raynigon.ecs.logging.access.context.IAccessLogContext;
import com.raynigon.ecs.logging.access.event.EcsAccessEvent;
import lombok.extern.slf4j.Slf4j;

import java.net.URL;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Logger;

@Slf4j
public class AccessLogContext implements IAccessLogContext, LifeCycle, Context, AppenderAttachable<IAccessEvent> {

private final AccessLogProperties config;
Expand All @@ -31,6 +34,7 @@ public class AccessLogContext implements IAccessLogContext, LifeCycle, Context,
private final Map<String, Object> objects;
private final URL configLocation;
private final AppenderAttachableImpl<IAccessEvent> appenderContainer;
private final List<ConfigurationEventListener> eventListeners = new ArrayList<>();
private SequenceNumberGenerator sequenceNumberGenerator;

private ExecutorService executorService;
Expand Down Expand Up @@ -71,14 +75,14 @@ public final void appendEvent(EcsAccessEvent event) {
}

public void start() {
executorService = ExecutorServiceUtil.newExecutorService();
executorService = ExecutorServiceUtil.newThreadPoolExecutor();

try {
JoranConfigurator jc = new JoranConfigurator();
jc.setContext(this);
jc.doConfigure(this.configLocation);
} catch (Throwable e) {
//TODO handle exception
log.error("Unable to start access log", e);
}

StatusPrinter.printInCaseOfErrorsOrWarnings(this);
Expand Down Expand Up @@ -163,6 +167,16 @@ public void setSequenceNumberGenerator(SequenceNumberGenerator sequenceNumberGen
this.sequenceNumberGenerator = sequenceNumberGenerator;
}

@Override
public void addConfigurationEventListener(ConfigurationEventListener listener) {
eventListeners.add(listener);
}

@Override
public void fireConfigurationEvent(ConfigurationEvent configurationEvent) {
eventListeners.forEach((listener) -> listener.listen(configurationEvent));
}

public ScheduledExecutorService getScheduledExecutorService() {
throw new UnsupportedOperationException();
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=2.0.1-SNAPSHOT
version=2.1.0-SNAPSHOT
org.gradle.caching=true

0 comments on commit 7bbcc28

Please sign in to comment.