Class AbstractOperationLogger

java.lang.Object
org.shoulder.log.operation.logger.AbstractOperationLogger
All Implemented Interfaces:
OperationLogger
Direct Known Subclasses:
JdbcOperationLogger, LogOperationLogger

public abstract class AbstractOperationLogger extends Object implements OperationLogger
基础操作日志记录,封装了记录前后触发逻辑 记录前先校验,若日志不符合自己的规范要求则不记录这条操作日志,并在运行日志中记录为什么不合规
Author:
lym
  • Field Details

    • log

      protected final org.slf4j.Logger log
  • Constructor Details

    • AbstractOperationLogger

      public AbstractOperationLogger()
  • Method Details

    • log

      public void log(@Nonnull OperationLogDTO opLog)
      记录一条操作日志
      Specified by:
      log in interface OperationLogger
      Parameters:
      opLog - 操作日志对象
    • log

      public void log(@Nonnull Collection<? extends OperationLogDTO> opLogList)
      记录多条操作日志 【性能】默认单条循环,扩展时可考虑覆盖默认实现,支持真正的批量操作 【扩展】自行实现时,也可自己定义批量记录前后置处理器
      Specified by:
      log in interface OperationLogger
      Parameters:
      opLogList - 操作日志对象集合
    • log

      public void log(@Nonnull OperationLogDTO opLog, List<? extends Operable> operableList)
      拼装循环记录多条操作日志
      Specified by:
      log in interface OperationLogger
      Parameters:
      opLog - 记录模板
      operableList - 被操作对象集合
    • doLog

      protected abstract void doLog(OperationLogDTO opLog)
      子类需要实现具体如何记录日志
      Parameters:
      opLog - 需要记录日志的实体
    • handleLogException

      protected void handleLogException(Exception e, OperationLogDTO opLog)
      默认记录一条warn日志,但子类可以覆盖当记录日志时出现异常如何处理
      Parameters:
      e - 具体是什么异常
      opLog - 需要记录日志的实体
    • addInterceptor

      public void addInterceptor(OperationLoggerInterceptor logInterceptor)
      Description copied from interface: OperationLogger
      注册拦截器
      Specified by:
      addInterceptor in interface OperationLogger
      Parameters:
      logInterceptor - 拦截器