4 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #ifndef __FOTA_LOG_H__
20 #define __FOTA_LOG_H__
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);
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
42 //#define 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)
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)
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);\
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);\
66 #define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
69 #define LOGE(s, args...)
70 #define LOGL(mask, s, args...)
71 #define LOG(s, args...)
75 #endif /* __FOTA_LOG_H__ */