open-card-table/oct_log.c

27 lines
519 B
C
Raw Normal View History

2023-05-23 10:59:37 -04:00
#include <stdio.h>
#include "oct_log.h"
FILE* oct_log_output_file;
int oct_log_level;
// If filename is null, default to stderr
int oct_log_init(char* filename, int level) {
if (filename) {
oct_log_output_file = fopen(filename, "w");
}
else {
oct_log_output_file = stderr;
}
oct_log_level = level;
OCT_LOG_INFO("Initialized logging, output file: %s", filename ? filename : "stderr");
return 1;
}
int oct_log_deinit() {
if (oct_log_output_file != stderr) {
fclose(oct_log_output_file);
}
return 1;
}