1 /*
2 * Copyright (C) 2021 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 #include "log_action.h"
16
17 #include "logger.h"
18 #include "string_util.h"
19 namespace OHOS {
20 namespace HiviewDFX {
21 DEFINE_LOG_LABEL(0xD002D01, "EventLogger-LogAction");
Init()22 void LogAction::Init()
23 {
24 logTask_ = std::make_unique<EventLogTask>(fd_, event_);
25 std::string cmdStr = event_->GetValue("eventLog_action");
26 StringUtil::SplitStr(cmdStr, ",", cmdList_);
27 }
28
CaptureAction()29 void LogAction::CaptureAction()
30 {
31 for (std::string cmd : cmdList_) {
32 logTask_->AddLog(cmd);
33 }
34 auto ret = logTask_->StartCompose();
35 if (ret != EventLogTask::TASK_SUCCESS) {
36 HIVIEW_LOGE("capture fail %{public}d", ret);
37 }
38 }
39 }
40 }