feat(日志): 访问日志增加过滤支持

This commit is contained in:
zhouhao 2023-03-27 10:26:45 +08:00
parent 4a421c980f
commit 8957c8b386
1 changed files with 6 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package org.jetlinks.community.logging.access;
import org.hswebframework.web.logging.events.AccessLoggerAfterEvent;
import org.jetlinks.community.logging.configuration.LoggingProperties;
import org.jetlinks.core.utils.TopicUtils;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
@ -20,6 +21,11 @@ public class AccessLoggingTranslator {
@EventListener
public void translate(AccessLoggerAfterEvent event) {
for (String pathExclude : properties.getAccess().getPathExcludes()) {
if (TopicUtils.match(pathExclude, event.getLogger().getUrl())) {
return;
}
}
eventPublisher.publishEvent(SerializableAccessLog.of(event.getLogger()));
}