45 int priority,
const char *file,
int line,
const char *fn,
50 ctx->
log_fn(ctx, priority, file, line, fn,
format, args);
55 int priority,
const char *file,
int line,
const char *fn,
56 const char *
format, va_list args)
58 fprintf(stderr,
"liblightify: %s: ", fn);
59 vfprintf(stderr,
format, args);
67 prio = strtol(priority, &endptr, 10);
68 if (endptr[0] ==
'\0' || isspace(endptr[0]))
70 if (strncmp(priority,
"err", 3) == 0)
72 if (strncmp(priority,
"info", 4) == 0)
74 if (strncmp(priority,
"debug", 5) == 0)
90 void (*log_fn)(
struct lightify_ctx *ctx,
int priority,
const char *file,
91 int line,
const char *fn,
const char *
format, va_list args))
93 if (!ctx)
return -EINVAL;
95 info(ctx,
"custom logging function %p registered\n", log_fn);
101 if (!ctx)
return -EINVAL;
107 if (!ctx)
return -EINVAL;
LIGHTIFY_EXPORT int lightify_set_log_fn(struct lightify_ctx *ctx, void(*log_fn)(struct lightify_ctx *ctx, int priority, const char *file, int line, const char *fn, const char *format, va_list args))
LIGHTIFY_EXPORT int lightify_set_log_priority(struct lightify_ctx *ctx, int priority)
LIGHTIFY_EXPORT int lightify_get_log_priority(struct lightify_ctx *ctx)
static void const char * format
#define info(ctx, arg...)
int log_priority(const char *priority)
void log_stderr(struct lightify_ctx *ctx, int priority, const char *file, int line, const char *fn, const char *format, va_list args)
void lightify_log(struct lightify_ctx *ctx, int priority, const char *file, int line, const char *fn, const char *format,...)
void(* log_fn)(struct lightify_ctx *ctx, int priority, const char *file, int line, const char *fn, const char *format, va_list args)