08c0972de47a0749eeb1e8bde113debaa18350cc
[platform/core/system/upgrade.git] / src / upgrade-apply-deltafs / engine / fota_log.h
1 /*
2  * upgrade-apply-deltafs
3  *
4  * Copyright (c) 2017 - 2022 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the License);
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #ifndef __FOTA_LOG_H__
20 #define __FOTA_LOG_H__
21
22 #include <stdio.h>
23
24 /*
25  * DEBUGGING FEATURE
26  */
27
28 extern unsigned int __log_level__;
29 extern FILE *__log_out_file__;
30 extern int log_printf(FILE* log_fp, char* format_str, ...);
31
32 #define LOG_INFO        (1<<8)
33 #define LOG_ENGINE      (1<<7)
34 #define LOG_FUNCS       (1<<6)
35 #define LOG_GUI         (1<<5)
36 #define LOG_DEBUG       (1<<4)
37 #define LOG_FILE        (1<<3)
38 #define LOG_FLASH       (1<<2)
39 #define LOG_SSENGINE    LOG_ENGINE
40
41 #define DEBUG_STDOUT
42 //#define DEBUG_FILE
43
44 #ifdef DEBUG_STDOUT
45 #define LOGE(s, args...) printf("UA/ERROR(%s)  " s, __func__, ##args)   // Error log
46 #define LOGL(mask, s, args...) do { if ((mask) & __log_level__) printf("UA/(%s): " s, __func__, ##args); } while (0)
47 #define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
48
49 #elif defined(DEBUG_FILE)
50 #define LOGE(s, args...) (void)log_printf(__log_out_file__, "UA/ERROR(%s)  " s, __func__, ##args)
51 #define LOGL(mask, s, args...) do { if ((mask) & __log_level__) (void)log_printf(__log_out_file__, "UA/(%s): " s , __func__, ##args); } while (0)
52 #define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
53
54 #elif defined(DEBUG_STDOUT_FILE)        // debug printf
55 #define LOGE(s, args...) do {\
56                                                 printf("UA/ERROR(%s)  " s, __func__, ##args);\
57                                                 (void)log_printf(__log_out_file__, "UA/ERROR(%s)  " s, __func__, ##args);\
58                                         } while (0)
59 #define LOGL(mask, s, args...) do { \
60                                                 if ((mask) & __log_level__) {\
61                                                         printf("UA/(%s): " s , __func__, ##args);\
62                                                         (void)log_printf(__log_out_file__, "UA/(%s): " s, __func__, ##args);\
63                                                 } \
64                                         } while (0)
65 #define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
66
67 #else
68 #define LOGE(s, args...)
69 #define LOGL(mask, s, args...)
70 #define LOG(s, args...)
71
72 #endif
73
74 #endif                          /* __FOTA_LOG_H__ */