12498b56bSopenharmony_ci/*
22498b56bSopenharmony_ci * Copyright (C) 2022 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//! hilog dylib_crate for Rust.
172498b56bSopenharmony_ciuse std::ffi::{c_char};
182498b56bSopenharmony_ci
192498b56bSopenharmony_ci#[macro_use]
202498b56bSopenharmony_cimod macros;
212498b56bSopenharmony_ci
222498b56bSopenharmony_ci/// log level
232498b56bSopenharmony_ci#[derive(Debug)]
242498b56bSopenharmony_cipub enum LogLevel {
252498b56bSopenharmony_ci    /// min log level
262498b56bSopenharmony_ci    LogLevelMin = 0,
272498b56bSopenharmony_ci    /// The "debug" level.
282498b56bSopenharmony_ci    ///
292498b56bSopenharmony_ci    /// Designates lower priority log.
302498b56bSopenharmony_ci    Debug = 3,
312498b56bSopenharmony_ci    /// The "info" level.
322498b56bSopenharmony_ci    ///
332498b56bSopenharmony_ci    /// Designates useful information.
342498b56bSopenharmony_ci    Info = 4,
352498b56bSopenharmony_ci    /// The "warn" level.
362498b56bSopenharmony_ci    ///
372498b56bSopenharmony_ci    /// Designates hazardous situations.
382498b56bSopenharmony_ci    Warn = 5,
392498b56bSopenharmony_ci    /// The "error" level.
402498b56bSopenharmony_ci    ///
412498b56bSopenharmony_ci    /// Designates very serious errors.
422498b56bSopenharmony_ci    Error = 6,
432498b56bSopenharmony_ci    /// The "fatal" level.
442498b56bSopenharmony_ci    ///
452498b56bSopenharmony_ci    /// Designates major fatal anomaly.
462498b56bSopenharmony_ci    Fatal = 7,
472498b56bSopenharmony_ci    /// max log level
482498b56bSopenharmony_ci    LogLevelMax,
492498b56bSopenharmony_ci}
502498b56bSopenharmony_ci
512498b56bSopenharmony_ci/// log type
522498b56bSopenharmony_ci#[derive(Debug)]
532498b56bSopenharmony_cipub enum LogType {
542498b56bSopenharmony_ci    /// log type for app log
552498b56bSopenharmony_ci    LogApp = 0,
562498b56bSopenharmony_ci    /// log type for init log
572498b56bSopenharmony_ci    LogInit = 1,
582498b56bSopenharmony_ci    /// log type for core log
592498b56bSopenharmony_ci    LogCore = 3,
602498b56bSopenharmony_ci    /// log type for kernel log
612498b56bSopenharmony_ci    LogKmsg = 4,
622498b56bSopenharmony_ci    /// max log type
632498b56bSopenharmony_ci    LogTypeMax,
642498b56bSopenharmony_ci}
652498b56bSopenharmony_ci
662498b56bSopenharmony_ci/// hilog label
672498b56bSopenharmony_ci#[derive(Debug)]
682498b56bSopenharmony_cipub struct HiLogLabel {
692498b56bSopenharmony_ci    /// log type
702498b56bSopenharmony_ci    pub log_type: LogType,
712498b56bSopenharmony_ci    /// log domain
722498b56bSopenharmony_ci    pub domain: u32,
732498b56bSopenharmony_ci    /// log tag
742498b56bSopenharmony_ci    pub tag: &'static str,
752498b56bSopenharmony_ci}
762498b56bSopenharmony_ci
772498b56bSopenharmony_ci// hilog ffi interface
782498b56bSopenharmony_ciextern "C" {
792498b56bSopenharmony_ci    /// hilog ffi interface HiLogIsLoggabel
802498b56bSopenharmony_ci    pub fn HiLogIsLoggable(domain: u32, tag: *const c_char, level: u32) -> bool;
812498b56bSopenharmony_ci    /// hilog ffi interface HiLogPrint
822498b56bSopenharmony_ci    pub fn HiLogPrint(
832498b56bSopenharmony_ci        logType: u8,
842498b56bSopenharmony_ci        level: u8,
852498b56bSopenharmony_ci        domain: u32,
862498b56bSopenharmony_ci        tag: *const c_char,
872498b56bSopenharmony_ci        fmt: *const c_char,
882498b56bSopenharmony_ci        ...
892498b56bSopenharmony_ci    ) -> u32;
902498b56bSopenharmony_ci    /// hilog ffi interface IsPrivateSwitchOn
912498b56bSopenharmony_ci    pub fn IsPrivateSwitchOn() -> bool;
922498b56bSopenharmony_ci    /// hilog ffi interface IsDebugOn
932498b56bSopenharmony_ci    pub fn IsDebugOn() -> bool;
942498b56bSopenharmony_ci}
95