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
16#ifndef LOG_COLLECTOR_H
17#define LOG_COLLECTOR_H
18#include <list>
19
20#include <properties.h>
21#include "log_buffer.h"
22#include "hilog_input_socket_server.h"
23
24namespace OHOS {
25namespace HiviewDFX {
26class LogCollector {
27public:
28    explicit LogCollector(HilogBuffer& buffer) : m_hilogBuffer(buffer)
29    {
30        countEnable = m_hilogBuffer.GetStatsInfo().IsEnable();
31        flowControl = IsDomainSwitchOn();
32        debug = IsPersistDebugOn();
33    }
34    void InsertDropInfo(const HilogMsg &msg, int droppedCount);
35    size_t InsertLogToBuffer(const HilogMsg& msg);
36#ifndef __RECV_MSG_WITH_UCRED_
37    void onDataRecv(std::vector<char>& data, int dataLen);
38#else
39    void onDataRecv(const ucred& cred, std::vector<char>& data, int dataLen);
40#endif
41    void SetLogFlowControl(bool on);
42    void SetDebuggable(bool on);
43    ~LogCollector() = default;
44private:
45    HilogBuffer& m_hilogBuffer;
46    bool countEnable;
47    bool flowControl;
48    bool debug;
49};
50} // namespace HiviewDFX
51} // namespace OHOS
52#endif
53