From 8baebb7886a93e71863ac94a24e10477a42c127e Mon Sep 17 00:00:00 2001 From: comex Date: Sun, 1 Mar 2015 19:16:24 -0500 Subject: minor changes --- darwin-bootstrap/ib-log.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'darwin-bootstrap/ib-log.h') diff --git a/darwin-bootstrap/ib-log.h b/darwin-bootstrap/ib-log.h index fee70b5..c80ae63 100644 --- a/darwin-bootstrap/ib-log.h +++ b/darwin-bootstrap/ib-log.h @@ -1,8 +1,13 @@ #pragma once #include #include +#include #include +#ifdef IB_LOG_TO_SYSLOG +#include +#define ib_log(fmt, args...) syslog(LOG_ERR, IB_LOG_NAME ": " fmt, ##args) +#else static FILE *logfp; static void open_logfp_if_necessary() { /* syslog() doesn't seem to work from launchd... */ @@ -23,5 +28,17 @@ static void open_logfp_if_necessary() { fprintf(logfp, fmt "\n", ##args); \ fflush(logfp); \ } while(0) +#endif -#define IB_VERBOSE 0 +static inline void ib_log_hex(const void *buf, size_t size) { + const uint8_t *up = buf; + char *hex = malloc(2 * size + 1), *p = hex; + for (size_t i = 0; i < size; i++) { + sprintf(p, "%02x", up[i]); + p += 2; + } + ib_log("%s", hex); + free(hex); +} + +#define IB_VERBOSE 1 -- cgit v1.2.3