/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to
 * deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */

#ifndef MUSL_HILOG_ADAPTER_H
#define MUSL_HILOG_ADAPTER_H

#include <features.h>
#include <log_base.h>
#include <stdarg.h>
#include <stdbool.h>

#ifndef hidden
#define hidden __attribute__((visibility("hidden")))
#endif

hidden bool CheckHilogValid();
// Dangerous operation, please do not use in normal business
hidden void RefreshHiLogSocketFd();

hidden void InitHilogSocketFd();

hidden int HiLogAdapterPrint(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...)
    __attribute__((__format__(os_log, 5, 6)));

hidden int HiLogAdapterPrintArgs(const LogType type, const LogLevel level, const unsigned int domain, const char *tag,
                                 const char *fmt, va_list ap);
hidden int HiLogAdapterVaList(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt,
                              va_list ap);

hidden bool HiLogAdapterIsLoggable(unsigned int domain, const char *tag, LogLevel level);

#ifdef OHOS_ENABLE_PARAMETER
#include "sys_param.h"
hidden bool get_bool_sysparam(CachedHandle cachedhandle);
#endif

hidden bool is_musl_log_enable();
hidden void musl_log_reset();

#endif  // MUSL_HILOG_ADAPTER_H