blob: 218ece1c594a3b6b05970f98e2c99736567c7986 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#ifndef UPI_LOG_H
2#define UPI_LOG_H
3
4
xf.li6c8fc1e2023-08-12 00:11:09 -07005extern FILE* s_FP_LOG;
6extern long cur_log_size;
lh9ed821d2023-04-07 01:36:19 -07007
xf.li6c8fc1e2023-08-12 00:11:09 -07008//#define FOTA_UPI_AB_LOG_ROOT "/cache/zte_fota_ab/"
9
10//#define FOTA_UPI_AB_LOG_PATH "/cache/zte_fota_ab/upi_ab.log"
11
12#define FOTA_LOG_PATH "fota_ab_log_path"
lh9ed821d2023-04-07 01:36:19 -070013
14
15#ifdef _IS_MIN
16
17
xf.li6c8fc1e2023-08-12 00:11:09 -070018#define upi_print(...) do { \
lh9ed821d2023-04-07 01:36:19 -070019 printf(__VA_ARGS__); \
20 } while(0)
21
22
23#else
24
xf.li6c8fc1e2023-08-12 00:11:09 -070025#define upi_print(...) do { \
lh9ed821d2023-04-07 01:36:19 -070026 printf(__VA_ARGS__); \
27 char buffer_log[512] = {0}; \
28 snprintf(buffer_log, 510, __VA_ARGS__); \
xf.li6c8fc1e2023-08-12 00:11:09 -070029 upi_fwrite(buffer_log); \
lh9ed821d2023-04-07 01:36:19 -070030 } while(0)
31
32
33#endif
34
35
36
37#define upi_log(fmt, args...) \
xf.li6c8fc1e2023-08-12 00:11:09 -070038 do {upi_print("[%s][fota_upi] [%s-%d]: " fmt"\n", upi_get_time_us(),__FUNCTION__, __LINE__, ## args);} while (0)
lh9ed821d2023-04-07 01:36:19 -070039#define upi_err(fmt, args...) \
xf.li6c8fc1e2023-08-12 00:11:09 -070040 do {upi_print("[%s][fota_upi] [%s-%d]: " fmt"\n", upi_get_time_us(),__FUNCTION__, __LINE__, ## args);} while (0)
lh9ed821d2023-04-07 01:36:19 -070041#if 0
42#define lib_log(fmt, args...) \
43 do {upi_print(FOTA_UPI_AB_LOG_PATH, "" fmt"\n", ## args);} while (0)
44#endif
45
46
47#define LOG_FUNC_BEGIN upi_log("%s func begin!", __func__);
48#define LOG_FUNC_END upi_log("%s func end!", __func__);
49
50
xf.li6c8fc1e2023-08-12 00:11:09 -070051void upi_fwrite(char* info);
lh9ed821d2023-04-07 01:36:19 -070052void upi_close_logfile(void);
53char * upi_get_time_us(void);
54
55unsigned int timestamp_now(void);
56
57#endif /*UPI_LOG_H*/