• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# coding=utf-8
3
4#
5# Copyright (c) 2020-2023 Huawei Device Co., Ltd.
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10#     http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18
19import os
20from _core.logger import add_task_file_handler
21from _core.logger import remove_task_file_handler
22from _core.logger import add_encrypt_file_handler
23from _core.logger import remove_encrypt_file_handler
24from _core.report.encrypt import check_pub_key_exist
25from _core.report.reporter_helper import ReportConstant
26
27
28__all__ = ["RuntimeLogs"]
29
30
31class RuntimeLogs:
32
33    @staticmethod
34    def start_task_log(log_path):
35        tool_file_name = ReportConstant.task_run_log
36        tool_log_file = os.path.join(log_path, tool_file_name)
37        add_task_file_handler(tool_log_file)
38
39    @staticmethod
40    def start_encrypt_log(log_path):
41        if check_pub_key_exist():
42            encrypt_file_name = "task_log.ept"
43            encrypt_log_file = os.path.join(log_path, encrypt_file_name)
44            add_encrypt_file_handler(encrypt_log_file)
45
46    @staticmethod
47    def stop_task_logcat():
48        remove_task_file_handler()
49
50    @staticmethod
51    def stop_encrypt_log():
52        if check_pub_key_exist():
53            remove_encrypt_file_handler()
54