加入重连机制忽略日志记录错误
This commit is contained in:
@@ -25,7 +25,14 @@ class LokiLogger implements Logger {
|
||||
BaseOptions(baseUrl: _config == null ? "" : _config.host, headers: {
|
||||
"Content-Type": "application/json",
|
||||
if (!identical(0, 0.0)) "Content-Encoding": "gzip"
|
||||
}));
|
||||
})) {
|
||||
dio.interceptors.add(InterceptorsWrapper(
|
||||
onError: (error, handler) => {
|
||||
//忽略异常
|
||||
print("logerr:###$error###")
|
||||
},
|
||||
));
|
||||
}
|
||||
@override
|
||||
void debug(String msg,
|
||||
{String? tag, String? traceId, String? spanId, String? parentSpanId}) {
|
||||
@@ -106,12 +113,14 @@ class LokiLogger implements Logger {
|
||||
]
|
||||
});
|
||||
//判断平台
|
||||
|
||||
if (identical(0, 0.0)) {
|
||||
dio.post("/loki/api/v1/push", data: data);
|
||||
} else {
|
||||
var zip = gzip.encode(utf8.encode(data));
|
||||
dio.post("/loki/api/v1/push", data: zip);
|
||||
}
|
||||
|
||||
if (level == LoggerLevel.debug || _config.print) {
|
||||
print(log);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user