#include<stdarg.h>
#include<stdio.h>
-#include<threads.h>
extern int verbose_flag;
LOG_LEVEL_VERBOSE = 3 /* logging and debugging info */
};
-extern thrd_t logging_thread;
-
#define log_err(...) log_enqueue(LOG_LEVEL_ERRORS,stderr,__VA_ARGS__)
#define log_info(...) log_enqueue(LOG_LEVEL_VERBOSE,stdout,__VA_ARGS__)
#define log_msg(...) log_enqueue(LOG_LEVEL_DEFAULT,stdout,__VA_ARGS__)
void log_enqueue(enum log_level,FILE*,const char*,...);
void log_message(enum log_level,FILE*,const char*,...);
+void log_poll();
#endif
--- /dev/null
+#ifndef __SETUP_H_
+#define __SETUP_H_
+
+#include<pthread.h>
+
+int setup();
+
+#endif
#include<default.h>
-thrd_t logging_thread;
-
int defaults() {
- logging_thread = thrd_current();
-
opt_set_log_level(LOG_LEVEL_DEFAULT);
return 1;
void log_message(enum log_level level, FILE *out_stream, const char *format,...) {
if(level>verbose_flag) { return; }
- if(thrd_equal(logging_thread,thrd_current)) {
+ if(thrd_equal(logging_thread,thrd_current())) {
va_list args;
va_start(args,format);
vfprintf(out_stream,message);
log_enqueue(level,out_stream,format,...);
}
}
+
+int log_poll(void *arg) {
+ while(1) {
+ }
+
+ return 1;
+}
log_msg("here?\n");
+ if(setup()<0) { return EXIT_FAILURE; }
+
+ log_msg("here!\n");
return EXIT_FAILURE;
}
--- /dev/null
+#include<setup.h>
+
+int setup() {
+ if(pthread_create(&logging_thread,&log_poll)!=0) {
+ perror("pthread_create");
+ return -1;
+ }
+}