주석 추가

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

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

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

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

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

Loading…
Cancel
Save