lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #ifndef UPI_LOG_H |
| 2 | #define UPI_LOG_H |
| 3 | |
| 4 | |
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 5 | extern FILE* s_FP_LOG; |
| 6 | extern long cur_log_size; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 7 | |
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 8 | //#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" |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 13 | |
| 14 | |
| 15 | #ifdef _IS_MIN |
| 16 | |
| 17 | |
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 18 | #define upi_print(...) do { \ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 19 | printf(__VA_ARGS__); \ |
| 20 | } while(0) |
| 21 | |
| 22 | |
| 23 | #else |
| 24 | |
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 25 | #define upi_print(...) do { \ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 26 | printf(__VA_ARGS__); \ |
| 27 | char buffer_log[512] = {0}; \ |
| 28 | snprintf(buffer_log, 510, __VA_ARGS__); \ |
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 29 | upi_fwrite(buffer_log); \ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 30 | } while(0) |
| 31 | |
| 32 | |
| 33 | #endif |
| 34 | |
| 35 | |
| 36 | |
| 37 | #define upi_log(fmt, args...) \ |
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 38 | do {upi_print("[%s][fota_upi] [%s-%d]: " fmt"\n", upi_get_time_us(),__FUNCTION__, __LINE__, ## args);} while (0) |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 39 | #define upi_err(fmt, args...) \ |
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 40 | do {upi_print("[%s][fota_upi] [%s-%d]: " fmt"\n", upi_get_time_us(),__FUNCTION__, __LINE__, ## args);} while (0) |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 41 | #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.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 51 | void upi_fwrite(char* info); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 52 | void upi_close_logfile(void); |
| 53 | char * upi_get_time_us(void); |
| 54 | |
| 55 | unsigned int timestamp_now(void); |
| 56 | |
| 57 | #endif /*UPI_LOG_H*/ |