package com.czg.config;

import com.mybatisflex.core.audit.AuditManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;

/**
 * @author Administrator
 */
@Configuration
@Slf4j(topic = "mybatis-flex-sql")
public class MybatisFlexConfig {
    public MybatisFlexConfig() {
        //开启审计功能
        AuditManager.setAuditEnable(true);

        //设置 SQL 审计收集器
        AuditManager.setMessageCollector(auditMessage ->
                log.info("[sql] time: {}, size: {},\n sql:{}",
                        auditMessage.getElapsedTime(), auditMessage.getQueryCount(), auditMessage.getFullSql())
        );
    }

}
