aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2010-12-01 15:47:21 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2010-12-01 15:47:21 -0500
commitf765ede58f3942e38e3d18d2b1637431cd70be19 (patch)
tree2f8ecd8d7cd9674b93979c51afd4131b7ae15855 /src
parentfa8f1206397467953a514fcf20a46584633a6993 (diff)
downloadNetNuke2-f765ede58f3942e38e3d18d2b1637431cd70be19.tar.gz
Created logging_flag variable to handle writing COM calls to a file.
There is not argument parsing enabled for this yet.
Diffstat (limited to 'src')
-rw-r--r--src/netnuke.c1
-rw-r--r--src/output_redirect.c29
2 files changed, 15 insertions, 15 deletions
diff --git a/src/netnuke.c b/src/netnuke.c
index acbbc82..b61bbee 100644
--- a/src/netnuke.c
+++ b/src/netnuke.c
@@ -37,6 +37,7 @@
pthread_mutex_t lock_global = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t lock_write = PTHREAD_MUTEX_INITIALIZER;
extern unsigned long total_written_bytes;
+int logging_flag = 0;
int verbose_flag = 0;
int bus_mask = 0;
int device_timeout = 0;
diff --git a/src/output_redirect.c b/src/output_redirect.c
index 0537639..48d7f02 100644
--- a/src/output_redirect.c
+++ b/src/output_redirect.c
@@ -27,7 +27,7 @@
#include <time.h>
#include "netnuke.h"
-extern int verbose_flag;
+extern int logging_flag;
int nnlogcleanup()
{
@@ -49,12 +49,15 @@ int COM(const char* func, char *format, ...)
char tmpstr[255];
int n;
- /*FILE *logfp = fopen(NNLOGFILE, "a+");
- if(logfp == NULL)
+ FILE *logfp = NULL;
+ if(logging_flag)
{
- COM(self, "Unable to open %s\n", NNLOGFILE);
- verbose_flag = 1;
- }*/
+ logfp = fopen(NNLOGFILE, "a+");
+ if(logfp == NULL)
+ {
+ fprintf(stderr, "Unable to open %s\n", NNLOGFILE);
+ }
+ }
va_list args;
va_start (args, format);
n = vsprintf (str, format, args);
@@ -63,19 +66,15 @@ int COM(const char* func, char *format, ...)
logtm = localtime(&logtime);
snprintf(timestr, sizeof(timestr), "%02d-%02d-%02d %02d:%02d:%02d", logtm->tm_year+1900, logtm->tm_mon+1, logtm->tm_mday, logtm->tm_hour, logtm->tm_min, logtm->tm_sec);
snprintf(tmpstr, sizeof(tmpstr), "%s _%s_: %s", timestr, func, str);
+ free(str);
- if(verbose_flag)
+ fprintf(stdout, "%s", tmpstr);
+ if(logging_flag)
{
- fprintf(stdout, "%s", tmpstr);
- //fprintf(logfp, "%s", tmpstr);
- }
- else
- {
- /*fprintf(logfp, "%s", tmpstr);*/
+ fprintf(logfp, "%s", tmpstr);
+ fclose(logfp);
}
- free(str);
- /*fclose(logfp);*/
return 0;
}