Add delta.ua - a binary to apply an upgrade of DELTA_FS type.
[platform/core/system/upgrade.git] / src / delta-ua / engine / fota_log.h
1 /*
2  * libtota
3  *
4  * Copyright (c) 2017 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 extern void set_max_logfile_size(void);
32
33 #define LOG_INFO        (1<<8)
34 #define LOG_ENGINE      (1<<7)
35 #define LOG_FUNCS       (1<<6)
36 #define LOG_GUI         (1<<5)
37 #define LOG_DEBUG       (1<<4)
38 #define LOG_FILE        (1<<3)
39 #define LOG_FLASH       (1<<2)
40 #define LOG_SSENGINE    LOG_ENGINE
41
42 //#define DEBUG_STDOUT
43 #define DEBUG_FILE
44
45 #ifdef DEBUG_STDOUT
46 #define LOGE(s, args...) printf("UA/ERROR(%s)  " s, __func__, ##args)   // Error log
47 #define LOGL(mask, s, args...) do { if ((mask) & __log_level__) printf("UA/(%s): " s, __func__, ##args); } while (0)
48 #define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
49
50 #elif defined(DEBUG_FILE)
51 #define LOGE(s, args...) (void)log_printf(__log_out_file__, "UA/ERROR(%s)  " s, __func__, ##args)
52 #define LOGL(mask, s, args...) do { if ((mask) & __log_level__) (void)log_printf(__log_out_file__, "UA/(%s): " s , __func__, ##args); } while (0)
53 #define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
54
55 #elif defined(DEBUG_STDOUT_FILE)        // debug printf
56 #define LOGE(s, args...) do {\
57                                                 printf("UA/ERROR(%s)  " s, __func__, ##args);\
58                                                 (void)log_printf(__log_out_file__, "UA/ERROR(%s)  " s, __func__, ##args);\
59                                         } while (0)
60 #define LOGL(mask, s, args...) do { \
61                                                 if ((mask) & __log_level__) {\
62                                                         printf("UA/(%s): " s , __func__, ##args);\
63                                                         (void)log_printf(__log_out_file__, "UA/(%s): " s, __func__, ##args);\
64                                                 } \
65                                         } while (0)
66 #define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
67
68 #else
69 #define LOGE(s, args...)
70 #define LOGL(mask, s, args...)
71 #define LOG(s, args...)
72
73 #endif
74
75 #endif                          /* __FOTA_LOG_H__ */