33#define _CRT_SECURE_NO_WARNINGS 1
53 env = getenv(
"PCP_LOG_LEVEL");
55 long lvl=strtol(env, &ret, 0);
62static void default_logfn(
pcp_loglvl_e mode,
const char *msg)
66 static struct timeval prev_timestamp={0, 0};
67 struct timeval cur_timestamp;
72 if ((prev_timestamp.tv_sec == 0) && (prev_timestamp.tv_usec == 0)) {
73 prev_timestamp=cur_timestamp;
76 diff=(cur_timestamp.tv_sec - prev_timestamp.tv_sec) * 1000000
77 + (cur_timestamp.tv_usec - prev_timestamp.tv_usec);
99 fprintf(stderr,
"%3llus %03llums %03lluus %-7s: %s\n",
100 (
long long int)diff / 1000000,
101 (
long long int)(diff % 1000000) / 1000, (
long long int)diff % 1000,
123 p = (
char*)malloc(size);
133 n=vsnprintf(p, size, fmt, ap);
138 if (n > -1 && n < size) {
150 np = (
char*)realloc(p, size);
159 (*logger)(log_level, p);
168 memset(buf, 0, buflen);
172 strerror_s(buf, buflen, errnum);
175 strerror_r(errnum, buf, buflen);
void(* external_logger)(pcp_loglvl_e, const char *)
int gettimeofday(struct timeval *tv, struct timezone *tz)
pcp_loglvl_e pcp_log_level
void pcp_set_loggerfn(external_logger ext_log)
void pcp_strerror(int errnum, char *buf, size_t buflen)
void pcp_logger(pcp_loglvl_e log_level, const char *fmt,...)
void pcp_logger_init(void)
#define PCP_MAX_LOG_LEVEL