• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2025 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 OH_SK_LOG_H
17 #define OH_SK_LOG_H
18 
19 #include <hilog/log.h>
20 
21 typedef enum {
22     Log_Debug,
23     Log_Info,
24     Log_Warn,
25     Log_Error,
26     Log_Fatal
27 } oh_sk_log_type;
28 
29 void oh_sk_file_log(oh_sk_log_type type, const char* msg, ...);
30 const char* oh_sk_log_type_str(oh_sk_log_type type);
31 
32 #ifdef OH_SK_LOG_TO_FILE
33 
34 #define OH_SK_LOG_INFO(msg) oh_sk_file_log(oh_sk_log_type::Log_Info, msg)
35 #define OH_SK_LOG_INFO_A(msg, ...) oh_sk_file_log(oh_sk_log_type::Log_Info, msg, ##__VA_ARGS__)
36 #define OH_SK_LOG_ERROR(msg) oh_sk_file_log(oh_sk_log_type::Log_Error, msg)
37 #define OH_SK_LOG_ERROR_A(msg, ...) oh_sk_file_log(oh_sk_log_type::Log_Error, msg, ##__VA_ARGS__)
38 #define OH_SK_LOG_DEBUG(msg) oh_sk_file_log(oh_sk_log_type::Log_Debug, msg)
39 #define OH_SK_LOG_DEBUG_A(msg, ...) oh_sk_file_log(oh_sk_log_type::Log_Debug, msg, ##__VA_ARGS__)
40 #define OH_SK_LOG_WARN(msg) oh_sk_file_log(oh_sk_log_type::Log_Warn, msg)
41 #define OH_SK_LOG_WARN_A(msg, ...) oh_sk_file_log(oh_sk_log_type::Log_Warn, msg, ##__VA_ARGS__)
42 #define OH_SK_LOG_FATAL(msg) oh_sk_file_log(oh_sk_log_type::Log_Fatal, msg)
43 #define OH_SK_LOG_FATAL_A(msg, ...) oh_sk_file_log(oh_sk_log_type::Log_Fatal, msg, ##__VA_ARGS__)
44 
45 #else
46 
47 #define OH_SK_LOG_INFO(msg) OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "Koala", msg)
48 #define OH_SK_LOG_INFO_A(msg, ...) OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "Koala", msg, ##__VA_ARGS__)
49 #define OH_SK_LOG_ERROR(msg) OH_LOG_Print(LOG_APP, LOG_ERROR, 0xFF00, "Koala", msg)
50 #define OH_SK_LOG_ERROR_A(msg, ...) OH_LOG_Print(LOG_APP, LOG_ERROR, 0xFF00, "Koala", msg, ##__VA_ARGS__)
51 #define OH_SK_LOG_DEBUG(msg) OH_LOG_Print(LOG_APP, LOG_DEBUG, 0xFF00, "Koala", msg)
52 #define OH_SK_LOG_DEBUG_A(msg, ...) OH_LOG_Print(LOG_APP, LOG_DEBUG, 0xFF00, "Koala", msg, ##__VA_ARGS__)
53 #define OH_SK_LOG_WARN(msg) OH_LOG_Print(LOG_APP, LOG_WARN, 0xFF00, "Koala", msg)
54 #define OH_SK_LOG_WARN_A(msg, ...) OH_LOG_Print(LOG_APP, LOG_WARN, 0xFF00, "Koala", msg, ##__VA_ARGS__)
55 #define OH_SK_LOG_FATAL(msg) OH_LOG_Print(LOG_APP, LOG_FATAL, 0xFF00, "Koala", msg)
56 #define OH_SK_LOG_FATAL_A(msg, ...) OH_LOG_Print(LOG_APP, LOG_FATAL, 0xFF00, "Koala", msg, ##__VA_ARGS__)
57 
58 #endif
59 
60 #endif // OH_SK_LOG_H