fix include issues
Signed-off-by: Aidan Hahn <aidan@aidanis.online>
This commit is contained in:
parent
9ee1aacd83
commit
7ff43f0346
2 changed files with 14 additions and 5 deletions
8
alog.c
8
alog.c
|
|
@ -25,6 +25,12 @@
|
|||
|
||||
#define TEST_ALOG_STATE() if (!ALOG_LOGGING_STATE) { _init_alog(); }
|
||||
|
||||
struct _global_logging_state *ALOG_LOGGING_STATE;
|
||||
int _alog_num_out_fds;
|
||||
int *_alog_out_fds;
|
||||
int _alog_num_err_fds;
|
||||
int *_alog_err_fds;
|
||||
|
||||
void _init_alog() {
|
||||
if (!ALOG_LOGGING_STATE) {
|
||||
ALOG_LOGGING_STATE = malloc(sizeof(struct _global_logging_state));
|
||||
|
|
@ -152,6 +158,7 @@ void alog (
|
|||
int size;
|
||||
if (severity != PRINT) {
|
||||
// GET TIMESTAMP
|
||||
// TODO: try to get this all into 1 call to sprintf
|
||||
time_t t = time(NULL);
|
||||
struct tm * p = localtime(&t);
|
||||
char *timestamp = malloc(strftime(NULL, 0, "[%c]", p) + 1);
|
||||
|
|
@ -159,6 +166,7 @@ void alog (
|
|||
char *msg_and_timestamp = malloc(sizeof(timestamp) + 1 + (strlen(message) + 1) + 2);
|
||||
sprintf(msg_and_timestamp, "%s %s\n", timestamp, message);
|
||||
free(timestamp);
|
||||
// TODO: Why even use msg_and_timestamp if I am going to write it wholesale into buffer?
|
||||
size = snprintf(NULL, 0, msg_and_timestamp, fmt_list);
|
||||
buffer = malloc(size + 1);
|
||||
sprintf(buffer, msg_and_timestamp, fmt_list);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue