aboutsummaryrefslogtreecommitdiffstats
path: root/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'log.c')
-rw-r--r--log.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/log.c b/log.c
index e69de29..a3c2798 100644
--- a/log.c
+++ b/log.c
@@ -0,0 +1,50 @@
+#include "log.h"
+
+int log_register_sub(int sub, int level, int loc, char *location)
+{
+ FILE *fd=NULL;
+
+ if ((sub < LOG_SUB_NONE) || (sub > LOG_SUB_NET))
+ {
+ printf("Cant register logging\n");
+ return -1;
+ }
+
+ if (loc == LOG_LOC_FILE)
+ {
+ fd = fopen(location, "a");
+ if (fd == NULL)
+ {
+ printf("Cant open file for logging %s\n", location);
+ return -1;
+ }
+
+ }
+
+ __logs[sub].disabled = 0;
+ __logs[sub].sub = sub;
+ __logs[sub].level = level;
+ __logs[sub].location = loc;
+ __logs[sub].fd = fd;
+ __logs[sub].fname = location;
+
+ return 0;
+}
+
+int log_init()
+{
+ int i;
+
+ for (i=0;i<NUM_OF_LOG;i++)
+ {
+ __logs[i].disabled = 1;
+ __logs[i].sub = LOG_SUB_NONE;
+ __logs[i].level = LOG_LEVEL_NONE;
+ __logs[i].location = LOG_LOC_STDIO;
+ __logs[i].fd = stdout;
+ __logs[i].fname = NULL;
+ }
+
+ return 0;
+}
+