类 FsLogger

java.lang.Object
cn.isliu.core.logging.FsLogger

public class FsLogger extends Object
统一日志管理器 提供结构化日志记录、敏感信息脱敏、性能监控等功能
从以下版本开始:
0.0.2
作者:
liu
  • 构造器详细资料

    • FsLogger

      public FsLogger()
  • 方法详细资料

    • apiCall

      public static void apiCall(String operation, String params, long duration)
      记录API调用日志
      参数:
      operation - API操作名称
      params - 请求参数
      duration - 执行时长(毫秒)
    • apiCall

      public static void apiCall(String operation, String params, long duration, Map<String,Object> context)
      记录API调用日志(带上下文信息)
      参数:
      operation - API操作名称
      params - 请求参数
      duration - 执行时长(毫秒)
      context - 上下文信息
    • error

      public static void error(ErrorCode errorCode, String message, String context, Throwable cause)
      记录错误日志
      参数:
      errorCode - 错误代码
      message - 错误消息
      context - 上下文信息
      cause - 异常原因
    • error

      public static void error(ErrorCode errorCode, String message)
      记录错误日志(简化版本)
      参数:
      errorCode - 错误代码
      message - 错误消息
    • info

      public static void info(String message, Object... args)
      记录信息日志
      参数:
      message - 日志消息
      args - 参数
    • warn

      public static void warn(String message, Object... args)
      记录警告日志
      参数:
      message - 日志消息
      args - 参数
    • debug

      public static void debug(String message, Object... args)
      记录调试日志
      参数:
      message - 日志消息
      args - 参数
    • trace

      public static void trace(String message, Object... args)
      记录跟踪日志
      参数:
      message - 日志消息
      args - 参数
    • logPerformance

      public static void logPerformance(String operation, long duration, boolean success)
      记录性能指标
      参数:
      operation - 操作名称
      duration - 执行时长
      success - 是否成功
    • getPerformanceMetrics

      public static Map<String,Long> getPerformanceMetrics()
      获取性能指标
      返回:
      性能指标映射
    • getOperationCounts

      public static Map<String,Long> getOperationCounts()
      获取操作计数
      返回:
      操作计数映射
    • resetMetrics

      public static void resetMetrics()
      重置性能指标
    • setMinLogLevel

      public static void setMinLogLevel(FsLogger.LogLevel level)
      设置最小日志级别
      参数:
      level - 日志级别
    • setSamplingRate

      public static void setSamplingRate(int rate)
      设置日志采样率
      参数:
      rate - 采样率(1表示不采样,10表示每10条记录1条)