LogRedactor class
日志脱敏工具。
默认对 Authorization、Cookie、Token、密码等敏感字段进行掩码, 避免日志和调试面板直接暴露凭据。
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
isSensitiveKey(
String key) → bool - 判断字段名是否为敏感字段(大小写、下划线、短横线不敏感)
-
redactData(
dynamic data, [int depth = 0]) → dynamic - 递归对 Map/List 中的敏感字段脱敏
-
redactHeaders(
Map< String, dynamic> headers) → Map<String, dynamic> - 对请求/响应头脱敏
-
redactJsonString(
String text) → dynamic - 如果字符串是 JSON,则解析后脱敏;否则按 query/form 规则脱敏
-
redactKeyValueText(
String text) → String -
对
a=1&token=abc这类 query/form 文本做敏感参数脱敏 -
redactUrl(
String url) → String - 对 URL 的 query 部分脱敏,保留 path 便于定位问题
-
toSafeJson(
dynamic data) → String - 生成可安全打印的 JSON/文本