12498b56bSopenharmony_ci/*
22498b56bSopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
32498b56bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
42498b56bSopenharmony_ci * you may not use this file except in compliance with the License.
52498b56bSopenharmony_ci * You may obtain a copy of the License at
62498b56bSopenharmony_ci *
72498b56bSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
82498b56bSopenharmony_ci *
92498b56bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
102498b56bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
112498b56bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
122498b56bSopenharmony_ci * See the License for the specific language governing permissions and
132498b56bSopenharmony_ci * limitations under the License.
142498b56bSopenharmony_ci */
152498b56bSopenharmony_ci
162498b56bSopenharmony_ci#ifndef LOG_COLLECTOR_H
172498b56bSopenharmony_ci#define LOG_COLLECTOR_H
182498b56bSopenharmony_ci#include <list>
192498b56bSopenharmony_ci
202498b56bSopenharmony_ci#include <properties.h>
212498b56bSopenharmony_ci#include "log_buffer.h"
222498b56bSopenharmony_ci#include "hilog_input_socket_server.h"
232498b56bSopenharmony_ci
242498b56bSopenharmony_cinamespace OHOS {
252498b56bSopenharmony_cinamespace HiviewDFX {
262498b56bSopenharmony_ciclass LogCollector {
272498b56bSopenharmony_cipublic:
282498b56bSopenharmony_ci    explicit LogCollector(HilogBuffer& buffer) : m_hilogBuffer(buffer)
292498b56bSopenharmony_ci    {
302498b56bSopenharmony_ci        countEnable = m_hilogBuffer.GetStatsInfo().IsEnable();
312498b56bSopenharmony_ci        flowControl = IsDomainSwitchOn();
322498b56bSopenharmony_ci        debug = IsPersistDebugOn();
332498b56bSopenharmony_ci    }
342498b56bSopenharmony_ci    void InsertDropInfo(const HilogMsg &msg, int droppedCount);
352498b56bSopenharmony_ci    size_t InsertLogToBuffer(const HilogMsg& msg);
362498b56bSopenharmony_ci#ifndef __RECV_MSG_WITH_UCRED_
372498b56bSopenharmony_ci    void onDataRecv(std::vector<char>& data, int dataLen);
382498b56bSopenharmony_ci#else
392498b56bSopenharmony_ci    void onDataRecv(const ucred& cred, std::vector<char>& data, int dataLen);
402498b56bSopenharmony_ci#endif
412498b56bSopenharmony_ci    void SetLogFlowControl(bool on);
422498b56bSopenharmony_ci    void SetDebuggable(bool on);
432498b56bSopenharmony_ci    ~LogCollector() = default;
442498b56bSopenharmony_ciprivate:
452498b56bSopenharmony_ci    HilogBuffer& m_hilogBuffer;
462498b56bSopenharmony_ci    bool countEnable;
472498b56bSopenharmony_ci    bool flowControl;
482498b56bSopenharmony_ci    bool debug;
492498b56bSopenharmony_ci};
502498b56bSopenharmony_ci} // namespace HiviewDFX
512498b56bSopenharmony_ci} // namespace OHOS
522498b56bSopenharmony_ci#endif
53