1 /* 2 * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef GETLOG_H 17 #define GETLOG_H 18 #include "sp_profiler.h" 19 #include "sp_log.h" 20 #include <string> 21 #include <filesystem> 22 namespace OHOS { 23 namespace SmartPerf { 24 class GetLog : public SpProfiler { 25 public: 26 std::map<std::string, std::string> ItemData() override; GetInstance()27 static GetLog &GetInstance() 28 { 29 static GetLog instance; 30 return instance; 31 } 32 void RemoveLogFile(); 33 34 private: GetLog()35 GetLog() {}; 36 GetLog(const GetLog &); 37 GetLog &operator = (const GetLog &); 38 void TarLogFile(); 39 int GetCurrentPath(char *currentPath); 40 void GetHilogInMemory(std::vector<std::filesystem::path> &fileList); 41 void GetHilogInData(std::vector<std::filesystem::path> &otherFiles, std::vector<std::filesystem::path> &logFiles); 42 void GenerateHilogFile(); 43 void GenerateDaemonLogFile(); 44 45 int logFileSocket = -1; 46 int logFileSocketPort = -1; 47 const std::string systemHilogFileDir = "/data/log/hilog/"; 48 const std::string hilogFileDir = LOG_FILE_DIR + "hilog/"; 49 const std::string daemonLogFileDir = LOG_FILE_DIR + "daemonLog/"; 50 const std::string logFilePath = LOG_FILE_DIR + "logfile.tar.gz"; 51 static const uintmax_t logMaxSize = 52428800; // 50MB = 50 * 1024 * 1024 52 uintmax_t currentLogSize = 0; 53 }; 54 } 55 } 56 #endif // NETWORK_H 57