lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #ifndef UPI_LOG_H |
| 2 | #define UPI_LOG_H |
| 3 | |
| 4 | |
| 5 | #define FOTA_UPI_AB_LOG_ROOT "/cache/zte_fota_ab/" |
| 6 | |
| 7 | #define FOTA_UPI_AB_LOG_PATH "/cache/zte_fota_ab/upi_ab.log" |
| 8 | |
| 9 | |
| 10 | #ifdef _IS_MIN |
| 11 | |
| 12 | |
| 13 | #define upi_print(ModID,...) do { \ |
| 14 | printf(__VA_ARGS__); \ |
| 15 | } while(0) |
| 16 | |
| 17 | |
| 18 | #else |
| 19 | |
| 20 | #define upi_print(ModID,...) do { \ |
| 21 | printf(__VA_ARGS__); \ |
| 22 | char buffer_log[512] = {0}; \ |
| 23 | snprintf(buffer_log, 510, __VA_ARGS__); \ |
| 24 | upi_fwrite(ModID,buffer_log); \ |
| 25 | } while(0) |
| 26 | |
| 27 | |
| 28 | #endif |
| 29 | |
| 30 | |
| 31 | |
| 32 | #define upi_log(fmt, args...) \ |
| 33 | do {upi_print(FOTA_UPI_AB_LOG_PATH, "[%s][fota_upi] [%s-%d]: " fmt"\n", upi_get_time_us(),__FUNCTION__, __LINE__, ## args);} while (0) |
| 34 | #define upi_err(fmt, args...) \ |
| 35 | do {upi_print(FOTA_UPI_AB_LOG_PATH, "[%s][fota_upi] [%s-%d]: " fmt"\n", upi_get_time_us(),__FUNCTION__, __LINE__, ## args);} while (0) |
| 36 | #if 0 |
| 37 | #define lib_log(fmt, args...) \ |
| 38 | do {upi_print(FOTA_UPI_AB_LOG_PATH, "" fmt"\n", ## args);} while (0) |
| 39 | #endif |
| 40 | |
| 41 | |
| 42 | #define LOG_FUNC_BEGIN upi_log("%s func begin!", __func__); |
| 43 | #define LOG_FUNC_END upi_log("%s func end!", __func__); |
| 44 | |
| 45 | |
| 46 | |
| 47 | void upi_fwrite(char *filename, char* info); |
| 48 | void upi_close_logfile(void); |
| 49 | char * upi_get_time_us(void); |
| 50 | |
| 51 | unsigned int timestamp_now(void); |
| 52 | |
| 53 | #endif /*UPI_LOG_H*/ |