From b274b48e3d266f9af87d1bf5109eda316da75b74 Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Tue, 18 Feb 2025 18:09:25 +0800 Subject: [PATCH] fix logger --- apps/iot/src/iot_logger.erl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/iot/src/iot_logger.erl b/apps/iot/src/iot_logger.erl index 138a909..7ffbd6b 100644 --- a/apps/iot/src/iot_logger.erl +++ b/apps/iot/src/iot_logger.erl @@ -88,10 +88,13 @@ handle_cast({write, Data}, State = #state{file = {OldIoDevice, OldFilePath}, que case maybe_new_file(Date, NDate) of true -> ok = file:close(OldIoDevice), - %% 压缩文件 - ok = erl_tar:create(OldFilePath ++ ".tar", [OldFilePath], [compressed]), - %% 删除原来的文件 - ok = file:delete(OldFilePath), + %% 归档 + erlang:spawn(fun() -> + %% 压缩文件 + ok = erl_tar:create(OldFilePath ++ ".tar", [OldFilePath], [compressed]), + %% 删除原来的文件 + ok = file:delete(OldFilePath) + end), %% 开启新的文件 NewFilePath = make_file(FileName, NDate),