gemstone/tests/logging/streams.c

39 lines
649 B
C
Raw Permalink Normal View History

//
// Created by servostar on 5/2/24.
//
#include "sys/log.h"
#include <stdlib.h>
2024-06-02 22:24:17 +00:00
#include <cfg/opt.h>
2024-06-05 18:00:14 +00:00
#include <mem/cache.h>
static FILE* file;
void close_file(void) {
if (file != NULL) {
fclose(file);
}
}
2024-06-02 22:24:17 +00:00
int main(int argc, char* argv[]) {
2024-06-05 18:00:14 +00:00
mem_init();
2024-06-02 22:24:17 +00:00
parse_options(argc, argv);
log_init();
2024-06-02 22:24:17 +00:00
set_log_level(LOG_LEVEL_DEBUG);
// this should appear in stderr
INFO("should only be in stderr");
file = fopen("tmp/test.log", "w");
if (file == NULL) {
PANIC("could not open file");
}
atexit(close_file);
log_register_stream(file);
INFO("should be in both");
return 0;
}