1 /* 2 * Copyright (C) 2023 Huawei Device Co., Ltd. 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 #ifndef EVENT_LOGGER_DMESG_CATCHER 16 #define EVENT_LOGGER_DMESG_CATCHER 17 18 #include <map> 19 #include <string> 20 #include <vector> 21 22 #include "sys_event.h" 23 24 #include "event_log_catcher.h" 25 namespace OHOS { 26 namespace HiviewDFX { 27 class DmesgCatcher : public EventLogCatcher { 28 public: 29 explicit DmesgCatcher(); ~DmesgCatcher()30 ~DmesgCatcher() override {}; 31 bool Initialize(const std::string& packageNam, int isWriteNewFile, int intParam2) override; 32 int Catch(int fd) override; 33 bool Init(std::shared_ptr<SysEvent> event); 34 35 private: 36 static const inline std::string FULL_DIR = "/data/log/eventlog/"; 37 bool needWriteSysrq_ = false; 38 bool isWriteNewFile_ = false; 39 std::shared_ptr<SysEvent> event_; 40 41 std::string DmesgSaveTofile(); 42 bool DumpDmesgLog(int fd); 43 bool WriteSysrq(); 44 }; 45 } // namespace HiviewDFX 46 } // namespace OHOS 47 #endif // EVENT_LOGGER_DMESG_CATCHER 48