aboutsummaryrefslogtreecommitdiffstats
path: root/log.c
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2017-11-26 00:23:12 +0000
committerFreeArtMan <dos21h@gmail.com>2017-11-26 00:23:12 +0000
commitd2ad84c6517902a7c7b64f39241a1b7a5f1d72f0 (patch)
tree3ed71c93599906f29276ec78ac4a0bb0d7bbd4ad /log.c
parent32f380fb86012c5dbc856d3c81acfde13f2803e8 (diff)
downloadagni-d2ad84c6517902a7c7b64f39241a1b7a5f1d72f0.tar.gz
agni-d2ad84c6517902a7c7b64f39241a1b7a5f1d72f0.zip
Added basic loging
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;
+}
+