William Brawner
b88fba9644
This code is absolutely horrendous in its current state, with poor error handling (where it's even present) and memory leaks galore. USE AT YOUR OWN RISK. I certainly won't be publishing it anywhere or speaking of it until it's in a much better state.
20 lines
503 B
C
20 lines
503 B
C
#include <stdarg.h>
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "log.h"
|
|
|
|
void write_log(int level, char * format, ...) {
|
|
if (level == LOG_DEBUG) return;
|
|
va_list args;
|
|
va_start(args, format);
|
|
int format_len = strlen(format);
|
|
char * new_format = malloc(format_len + 1);
|
|
memcpy(new_format, format, format_len);
|
|
new_format[format_len] = '\n';
|
|
new_format[format_len + 1] = '\0';
|
|
vprintf(new_format, args);
|
|
va_end(args);
|
|
}
|
|
|