27 lines
519 B
C
27 lines
519 B
C
|
#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;
|
||
|
}
|