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 truncate_log_file(char *log_path, int size_kb);
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)
41 #define LOG_SSENGINE LOG_ENGINE
43 //#define DEBUG_STDOUT
47 #define LOGE(s, args...) printf("UA/ERROR(%s) " s, __func__, ##args) // Error log
48 #define LOGL(mask, s, args...) do{if((mask) & __log_level__) printf("UA/(%s): " s,__func__, ##args);}while(0)
49 #define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
51 #elif defined(DEBUG_FILE)
52 #define LOGE(s, args...) (void)log_printf(__log_out_file__, "UA/ERROR(%s) " s, __func__, ##args)
53 #define LOGL(mask, s, args...) do{if((mask) & __log_level__) (void)log_printf(__log_out_file__, "UA/(%s): " s ,__func__, ##args);}while(0)
54 #define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
56 #elif defined(DEBUG_STDOUT_FILE) // debug printf
57 #define LOGE(s, args...) do {\
58 printf("UA/ERROR(%s) " s, __func__, ##args);\
59 (void)log_printf(__log_out_file__, "UA/ERROR(%s) " s, __func__, ##args);\
61 #define LOGL(mask, s, args...) do{ \
62 if((mask) & __log_level__){\
63 printf("UA/(%s): " s ,__func__, ##args);\
64 (void)log_printf(__log_out_file__, "UA/(%s): " s,__func__, ##args);\
67 #define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
70 #define LOGE(s, args...)
71 #define LOGL(mask, s, args...)
72 #define LOG(s, args...)
76 #endif /* __FOTA_LOG_H__ */