From 3bbefe10b75be449da4a02428422dbd8f98a10fd Mon Sep 17 00:00:00 2001 From: deveco_xdevice Date: Wed, 8 Nov 2023 16:58:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9hilog=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=BC=80=E5=90=AFdebug=E7=BA=A7=E5=88=AB?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: deveco_xdevice --- plugins/ohos/src/ohos/environment/device.py | 30 +++++++++------------ src/xdevice/_core/config/config_manager.py | 3 ++- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/plugins/ohos/src/ohos/environment/device.py b/plugins/ohos/src/ohos/environment/device.py index 8c6b781..d83c6f3 100644 --- a/plugins/ohos/src/ohos/environment/device.py +++ b/plugins/ohos/src/ohos/environment/device.py @@ -886,6 +886,17 @@ class DeviceLogCollector: def __init__(self, device): self.device = device + def _set_device_log_level(self, **kwargs): + # set device log level + if not self.device_log_level: + log_level = kwargs.get("log_level", "INFO") + if log_level not in LOGLEVEL: + self.device_log_level = "INFO" + else: + self.device_log_level = log_level + cmd = "hilog -b {}".format(self.device_log_level) + self.device.execute_shell_command(cmd) + def restart_catch_device_log(self): self._sync_device_time() for _, path in enumerate(self.hilog_file_address): @@ -910,15 +921,7 @@ class DeviceLogCollector: the logs in files. """ self._sync_device_time() - # set device log level - if not self.device_log_level: - log_level = kwargs.get("log_level", "DEBUG") - if log_level not in LOGLEVEL: - self.device_log_level = "DEBUG" - else: - self.device_log_level = log_level - cmd = "hilog -b {}".format(self.device_log_level) - self.device.execute_shell_command(cmd) + self._set_device_log_level(**kwargs) device_hilog_proc = None if hilog_file_pipe: @@ -971,14 +974,7 @@ class DeviceLogCollector: self.device.execute_shell_command(cmd) cmd = "rm -rf /data/log/hilog/*.gz" # set device log level - if not self.device_log_level: - log_level = kwargs.get("log_level", "DEBUG") - if log_level not in LOGLEVEL: - self.device_log_level = "DEBUG" - else: - self.device_log_level = log_level - cmd = "hilog -b {}".format(self.device_log_level) - self.device.execute_shell_command(cmd) + self._set_device_log_level(**kwargs) # 开始日志任务 设置落盘文件个数最大值1000, 单个文件20M,链接https://gitee.com/openharmony/hiviewdfx_hilog cmd = "hilog -w start -l {} -n 1000".format(log_size) out = self.device.execute_shell_command(cmd) diff --git a/src/xdevice/_core/config/config_manager.py b/src/xdevice/_core/config/config_manager.py index bbe4c19..1f1d9a5 100644 --- a/src/xdevice/_core/config/config_manager.py +++ b/src/xdevice/_core/config/config_manager.py @@ -256,7 +256,8 @@ class UserConfigManager(object): else: data_dic.update({ConfigConst.tag_enable: str(node.text).strip()}) data_dic.update({ConfigConst.tag_dir: None}) - data_dic.update({ConfigConst.tag_loglevel: "DEBUG"}) + data_dic.update({ConfigConst.tag_loglevel: "INFO"}) + data_dic.update({ConfigConst.tag_clear: "TRUE"}) return data_dic def environment_enable(self):