42 lines
3.1 KiB
HTML
42 lines
3.1 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>AuthAuditLoggingConfiguration.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">project-auth-server</a> > <a href="index.source.html" class="el_package">com.project.auth.config.logging</a> > <span class="el_source">AuthAuditLoggingConfiguration.java</span></div><h1>AuthAuditLoggingConfiguration.java</h1><pre class="source lang-java linenums">package com.project.auth.config.logging;
|
|
|
|
import com.project.auth.application.support.audit.AuditLevel;
|
|
import com.project.auth.application.support.audit.AuthAuditEvent;
|
|
import com.project.auth.application.support.audit.AuthAuditEventPublisher;
|
|
import com.project.auth.application.support.audit.AuthAuditFields;
|
|
import com.project.auth.application.support.logging.LogSanitizer;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.spi.LoggingEventBuilder;
|
|
import org.springframework.context.ApplicationEventPublisher;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.event.EventListener;
|
|
|
|
@Configuration
|
|
public class AuthAuditLoggingConfiguration {
|
|
|
|
private static final Logger audit = LoggerFactory.getLogger("audit.auth");
|
|
|
|
@Bean
|
|
public AuthAuditEventPublisher authAuditEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
|
|
return applicationEventPublisher::publishEvent;
|
|
}
|
|
|
|
@Bean
|
|
public AuthAuditEventLogListener authAuditEventListener() {
|
|
return new AuthAuditEventLogListener();
|
|
}
|
|
|
|
<span class="fc" id="L31"> static final class AuthAuditEventLogListener {</span>
|
|
|
|
@EventListener
|
|
public void onAuthAuditEvent(AuthAuditEvent event) {
|
|
<span class="pc bpc" id="L35" title="1 of 2 branches missed."> LoggingEventBuilder builder = event.level() == AuditLevel.WARN ? audit.atWarn() : audit.atInfo();</span>
|
|
<span class="fc" id="L36"> builder.addKeyValue(AuthAuditFields.EVENT_TYPE, event.eventType());</span>
|
|
<span class="fc" id="L37"> event.fields().forEach((key, value) -> builder.addKeyValue(key, LogSanitizer.normalize(value)));</span>
|
|
<span class="fc" id="L38"> builder.log(event.eventType());</span>
|
|
<span class="fc" id="L39"> }</span>
|
|
}
|
|
}
|
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.14.202510111229</span></div></body></html> |