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);
|
||||
|
|
|
|||
11
alog.h
11
alog.h
|
|
@ -30,7 +30,7 @@ struct _global_logging_state {
|
|||
* I am sticking with it here.
|
||||
*
|
||||
* Alloc'ed/Initialized by a call to init_alog()*/
|
||||
struct _global_logging_state *ALOG_LOGGING_STATE;
|
||||
extern struct _global_logging_state *ALOG_LOGGING_STATE;
|
||||
|
||||
/* alternative impl I didnt want to write
|
||||
* it would have required a bunch of getters and setters
|
||||
|
|
@ -42,10 +42,10 @@ struct _global_logging_state *ALOG_LOGGING_STATE;
|
|||
#define LOG_DEBUG_MSGS_FIELD = 2;
|
||||
int flags = 0; */
|
||||
|
||||
int _alog_num_out_fds;
|
||||
int *_alog_out_fds;
|
||||
int _alog_num_err_fds;
|
||||
int *_alog_err_fds;
|
||||
extern int _alog_num_out_fds;
|
||||
extern int *_alog_out_fds;
|
||||
extern int _alog_num_err_fds;
|
||||
extern int *_alog_err_fds;
|
||||
|
||||
typedef enum {
|
||||
// Not printed by default. Useful for debug info
|
||||
|
|
@ -84,4 +84,5 @@ void alog(alog_sev, const char *, ...);
|
|||
#ifdef ALOG_HIJACK_PRINTF
|
||||
int printf(const char *format, ...);
|
||||
#endif // ALOG_HIJACK_PRINTF
|
||||
|
||||
#endif // ALOG_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue