주석 추가

master
mjkhan21 9 months ago
parent 23fa45fc12
commit 7a0f792fdc

@ -8,9 +8,15 @@ import cokr.xit.foundation.Access;
import cokr.xit.foundation.Assert;
import cokr.xit.foundation.UserInfo;
/**
* @author mjkhan
*/
public class ServiceCall {
private static final ThreadLocal<ServiceCall> cache = new ThreadLocal<>();
/** .
* @return
*/
public static final ServiceCall get() {
ServiceCall call = cache.get();
if (call == null) {
@ -21,6 +27,9 @@ public class ServiceCall {
return call;
}
/** .
* @return ServiceLog
*/
public static final ServiceLog controllerLog() {
ServiceCall call = get();
@ -31,16 +40,27 @@ public class ServiceCall {
return !Assert.isEmpty(url) ? log : null;
}
/** .
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
public static final boolean controllerStarted() {
return controllerLog() != null;
}
/** ServiceLog .
* @param log ServiceLog
*/
public static final void set(ServiceLog log) {
if (log == null) return;
get().add(log);
}
/** .
*/
public static final void remove() {
ServiceCall call = cache.get();
if (call != null) {

@ -22,23 +22,33 @@ public class ServiceLog {
private static final Config conf;
static {
try (InputStream input = new ClassPathResource("conf/xit-syslog.conf").getInputStream();) {
try (InputStream input = new ClassPathResource("xit-syslog.conf").getInputStream();) {
conf = new JSON().parse(input, Config.class);
} catch (Exception e) {
throw Assert.runtimeException(e);
}
}
/** .
* @return
*/
public static final Config config() {
return conf;
}
public static final String
LOG_INOUT = "log-inout",
DOWNLOAD = "download",
WEB = "web",
SERVICE = "service";
/** 로그유형 - 로그인/아웃 */
public static final String LOG_INOUT = "log-inout";
/** 로그유형 - 다운로드 */
public static final String DOWNLOAD = "download";
/** 로그유형 - 컨트롤러 */
public static final String WEB = "web";
/** 로그유형 - 서비스 */
public static final String SERVICE = "service";
/**joinPoint ServiceLog .
* @param joinPoint JoinPoint
* @return ServiceLog
*/
public static ServiceLog create(JoinPoint joinPoint) {
ServiceLog log = new ServiceLog();
@ -326,6 +336,9 @@ public class ServiceLog {
);
}
/** . xit-syslog.conf .
* @author mjkhan
*/
public static class Config {
private Exclude exclude;
private List<PersonalField> personalFields;
@ -359,6 +372,9 @@ public class ServiceLog {
}
}
/**
* @author mjkhan
*/
public static class Exclude {
private Set<String>
classes,
@ -393,6 +409,9 @@ public class ServiceLog {
}
}
/**
* @author mjkhan
*/
public static class PersonalField {
private String
name,

@ -10,8 +10,16 @@ import cokr.xit.foundation.component.AbstractMapper;
*/
@Mapper("loggingMapper")
public interface LoggingMapper extends AbstractMapper {
/** .
* @param log
* @return
*/
int insertLog(ServiceLog log);
/** .
* @param log
* @return
*/
default int insertLogs(Iterable<ServiceLog> logs) {
if (isEmpty(logs)) return 0;

@ -13,18 +13,33 @@ import cokr.xit.base.syslog.ServiceLog;
import cokr.xit.foundation.AbstractComponent;
import cokr.xit.foundation.data.DataObject;
/** .
* , .
* @author mjkhan
*/
public class LogFilter extends AbstractComponent {
private PersonalInfo personalInfo = new PersonalInfo();
public boolean filter(ServiceLog svcLog) {
/** , .
* , .
* @param log .
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
public boolean filter(ServiceLog log) {
for (Predicate<ServiceLog> filter: getFilters()) {
if (!filter.test(svcLog))
if (!filter.test(log))
return false;
}
return true;
}
/** .
* @return
*/
protected List<Predicate<ServiceLog>> getFilters() {
ArrayList<Predicate<ServiceLog>> filters = new ArrayList<>();
@ -36,6 +51,13 @@ public class LogFilter extends AbstractComponent {
return filters;
}
/** / .
* @param log
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
protected boolean authenticationFilter(ServiceLog log) {
if (!log.getClassName().contains("AuthenticationService"))
return true;
@ -50,6 +72,13 @@ public class LogFilter extends AbstractComponent {
}
}
/** .
* @param log
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
protected boolean configuredFilter(ServiceLog log) {
String name = log.getClassName();
for (String exclude: ServiceLog.config().getExclude().getClasses()) {
@ -65,6 +94,24 @@ public class LogFilter extends AbstractComponent {
return true;
}
/** .
* <ul><li></li>
* <li> </li>
* <li> </li>
* <li> </li>
* </ul>
* . ModelAndView
* <ul><li>viewName 'downloadView' 'xlsView'</li>
* <li> 'downloadData'</li>
* <li> 'dataNames'</li>
* </ul>
* .
* @param log
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
protected boolean downloadFilter(ServiceLog log) {
Object returned = log.getReturned();
if (returned instanceof ModelAndView) {
@ -80,6 +127,11 @@ public class LogFilter extends AbstractComponent {
return true;
}
/**ModelAndView 'downloadData'
* , , .
* @param log
* @param model ModelAndView model
*/
protected void setDownloadData(ServiceLog log, Map<String, Object> model) {
Object obj = model.get("downloadData");
if (!(obj instanceof List)) return;
@ -103,6 +155,13 @@ public class LogFilter extends AbstractComponent {
log.setDataNames(model.get("dataNames"));
}
/** .
* @param log
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
protected boolean customFilter(ServiceLog log) {
return true;
}

@ -8,15 +8,26 @@ import cokr.xit.base.syslog.ServiceLog;
import cokr.xit.base.syslog.dao.LoggingMapper;
import cokr.xit.foundation.component.AbstractBean;
@Component("loggingBean")
/**
* @author mjkhan
*/
@Component
public class LoggingBean extends AbstractBean {
@Resource(name = "loggingMapper")
private LoggingMapper loggingMapper;
/** .
* @param log
* @return
*/
public int create(ServiceLog log) {
return log != null ? loggingMapper.insertLog(log) : 0;
}
/** .
* @param logs
* @return
*/
public int create(Iterable<ServiceLog> logs) {
return loggingMapper.insertLogs(logs);
}

Loading…
Cancel
Save