LibC: Make {open,sys,close}log use their own FILE instead of stddbg
This commit is contained in:
parent
6beaafcf11
commit
00c6820825
|
@ -1,13 +1,16 @@
|
|||
#include <BAN/Assert.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
|
||||
static const char* s_ident = nullptr;
|
||||
|
||||
static FILE* s_log_file = nullptr;
|
||||
|
||||
void openlog(const char* ident, int option, int facility)
|
||||
{
|
||||
if (s_log_file == nullptr)
|
||||
s_log_file = fopen("/dev/debug", "w");
|
||||
|
||||
(void)option;
|
||||
(void)facility;
|
||||
s_ident = ident;
|
||||
|
@ -17,14 +20,16 @@ void syslog(int priority, const char* format, ...)
|
|||
{
|
||||
(void)priority;
|
||||
if (s_ident)
|
||||
fprintf(stddbg, "%s", s_ident);
|
||||
fprintf(s_log_file, "%s", s_ident);
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vfprintf(stddbg, format, args);
|
||||
vfprintf(s_log_file, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void closelog()
|
||||
{
|
||||
fclose(s_log_file);
|
||||
s_log_file = nullptr;
|
||||
s_ident = nullptr;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue