1dfe32fa1Soh_ci/* 2dfe32fa1Soh_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 3dfe32fa1Soh_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4dfe32fa1Soh_ci * you may not use this file except in compliance with the License. 5dfe32fa1Soh_ci * You may obtain a copy of the License at 6dfe32fa1Soh_ci * 7dfe32fa1Soh_ci * http://www.apache.org/licenses/LICENSE-2.0 8dfe32fa1Soh_ci * 9dfe32fa1Soh_ci * Unless required by applicable law or agreed to in writing, software 10dfe32fa1Soh_ci * distributed under the License is distributed on an "AS IS" BASIS, 11dfe32fa1Soh_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12dfe32fa1Soh_ci * See the License for the specific language governing permissions and 13dfe32fa1Soh_ci * limitations under the License. 14dfe32fa1Soh_ci */ 15dfe32fa1Soh_ci 16dfe32fa1Soh_ci//! This module defines the macros required for log printing. 17dfe32fa1Soh_ci 18dfe32fa1Soh_ciuse std::ffi::{c_char, CString}; 19dfe32fa1Soh_ci 20dfe32fa1Soh_ciuse hilog_rust::hilog; 21dfe32fa1Soh_ci 22dfe32fa1Soh_ci/// the function to print log, and may be should not be used instead of logi 23dfe32fa1Soh_cipub fn log_func_i(log: &str) { 24dfe32fa1Soh_ci let log_label = hilog_rust::HiLogLabel { log_type: hilog_rust::LogType::LogCore, domain: 0xD002F08, tag: "Asset" }; 25dfe32fa1Soh_ci hilog_rust::info!(log_label, "{}", @public(log)); 26dfe32fa1Soh_ci} 27dfe32fa1Soh_ci 28dfe32fa1Soh_ci/// the function to print log, and may be should not be used instead of logw 29dfe32fa1Soh_cipub fn log_func_w(log: &str) { 30dfe32fa1Soh_ci let log_label = hilog_rust::HiLogLabel { log_type: hilog_rust::LogType::LogCore, domain: 0xD002F08, tag: "Asset" }; 31dfe32fa1Soh_ci hilog_rust::warn!(log_label, "{}", @public(log)); 32dfe32fa1Soh_ci} 33dfe32fa1Soh_ci 34dfe32fa1Soh_ci/// the function to print log, and may be should not be used instead of loge 35dfe32fa1Soh_cipub fn log_func_e(log: &str) { 36dfe32fa1Soh_ci let log_label = hilog_rust::HiLogLabel { log_type: hilog_rust::LogType::LogCore, domain: 0xD002F08, tag: "Asset" }; 37dfe32fa1Soh_ci hilog_rust::error!(log_label, "{}", @public(log)); 38dfe32fa1Soh_ci} 39dfe32fa1Soh_ci 40dfe32fa1Soh_ci/// Print logs at the info level. 41dfe32fa1Soh_ci/// 42dfe32fa1Soh_ci/// # Examples 43dfe32fa1Soh_ci/// 44dfe32fa1Soh_ci/// ``` 45dfe32fa1Soh_ci/// logi!("hello, {}", "world"); 46dfe32fa1Soh_ci/// ``` 47dfe32fa1Soh_ci#[macro_export] 48dfe32fa1Soh_cimacro_rules! logi { 49dfe32fa1Soh_ci ($($arg:tt)*) => ( 50dfe32fa1Soh_ci $crate::log_func_i(&format!($($arg)*)); 51dfe32fa1Soh_ci ); 52dfe32fa1Soh_ci} 53dfe32fa1Soh_ci 54dfe32fa1Soh_ci/// Print logs at the info level. 55dfe32fa1Soh_ci/// 56dfe32fa1Soh_ci/// # Examples 57dfe32fa1Soh_ci/// 58dfe32fa1Soh_ci/// ``` 59dfe32fa1Soh_ci/// logw!("hello, {}", "world"); 60dfe32fa1Soh_ci/// ``` 61dfe32fa1Soh_ci#[macro_export] 62dfe32fa1Soh_cimacro_rules! logw { 63dfe32fa1Soh_ci ($($arg:tt)*) => ( 64dfe32fa1Soh_ci $crate::log_func_w(&format!($($arg)*)); 65dfe32fa1Soh_ci ); 66dfe32fa1Soh_ci} 67dfe32fa1Soh_ci 68dfe32fa1Soh_ci/// Print logs at the error level. 69dfe32fa1Soh_ci/// 70dfe32fa1Soh_ci/// # Examples 71dfe32fa1Soh_ci/// 72dfe32fa1Soh_ci/// ``` 73dfe32fa1Soh_ci/// loge!("Error message: {}", "read file failed"); 74dfe32fa1Soh_ci/// ``` 75dfe32fa1Soh_ci#[macro_export] 76dfe32fa1Soh_cimacro_rules! loge { 77dfe32fa1Soh_ci ($($arg:tt)*) => ( 78dfe32fa1Soh_ci $crate::log_func_e(&format!($($arg)*)); 79dfe32fa1Soh_ci ); 80dfe32fa1Soh_ci} 81