static void default_logger(const char *file, const char *func, int line, int level, const char *fmt, ...) { const char *fp; char *data; va_list ap; int ret; if (level < 0 || level > 7) { level = 7; } if (level > esl_log_level) { return; } fp = cut_path(file); va_start(ap, fmt); ret = esl_vasprintf(&data, fmt, ap); if (ret != -1) { fprintf(stderr, "[%s] %s:%d %s() %s", LEVEL_NAMES[level], fp, line, func, data); free(data); } va_end(ap); }
ESL_DECLARE(esl_status_t) esl_event_add_header(esl_event_t *event, esl_stack_t stack, const char *header_name, const char *fmt, ...) { int ret = 0; char *data; va_list ap; va_start(ap, fmt); ret = esl_vasprintf(&data, fmt, ap); va_end(ap); if (ret == -1) { return ESL_FAIL; } return esl_event_base_add_header(event, stack, header_name, data); }
ESL_DECLARE(esl_status_t) esl_event_add_body(esl_event_t *event, const char *fmt, ...) { int ret = 0; char *data; va_list ap; if (fmt) { va_start(ap, fmt); ret = esl_vasprintf(&data, fmt, ap); va_end(ap); if (ret == -1) { return ESL_FAIL; } else { esl_safe_free(event->body); event->body = data; return ESL_SUCCESS; } } else { return ESL_FAIL; } }