#ifndef __LOGGER_H__
#define __LOGGER_H__

/* output log's level */
#define CLOG_LVL_ASSERT                      0
#define CLOG_LVL_ERROR                       1
#define CLOG_LVL_WARN                        2
#define CLOG_LVL_INFO                        3
#define CLOG_LVL_DEBUG                       4
#define CLOG_LVL_VERBOSE                     5

#define LOG_TAG    "TCU"

#define CLOG_LINE_SIZE  512
#define CLOG_BUFF_SIZE  (CLOG_LINE_SIZE*64)

void clog_bind_serverip(const char* serverip, short port);

int clog_sendto_serverip(uint8_t *loginfo);

int clog_print(int level, const char *tag, const char* FUNCNAME, const char* FILENAME, int LINENO, const char *format, ...);

void clog_init(const char* log_filename, int max_filesize, int max_filenumb);

void clog_exit(void);

// #define log_a(...)       clog_print(CLOG_LVL_ASSERT,  LOG_TAG, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
// #define log_e(...)       clog_print(CLOG_LVL_ERROR,   LOG_TAG, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
// #define log_w(...)       clog_print(CLOG_LVL_WARN,    LOG_TAG, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
// #define log_i(...)       clog_print(CLOG_LVL_INFO,    LOG_TAG, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
// #define log_d(...)       clog_print(CLOG_LVL_DEBUG,   LOG_TAG, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
// #define log_v(...)       clog_print(CLOG_LVL_VERBOSE, LOG_TAG, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)

#define printe(...)      clog_print(CLOG_LVL_ERROR,   LOG_TAG, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
#define printd(...)      clog_print(CLOG_LVL_DEBUG,   LOG_TAG, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
#define printi(...)      clog_print(CLOG_LVL_INFO,    LOG_TAG, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)

// #define printd(fmt, ...)  printf("%s:%d, %s | "fmt, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
// #define printe(fmt, ...)  printf("%s:%d, %s(%d:%s) | "fmt, __FILE__, __LINE__, __FUNCTION__,, strerror(errno), __VA_ARGS__)

#endif//__LOGGER_H__
