* Added global variable silc_log_timestamp that tells silclog
[silc.git] / lib / silcutil / silclog.c
index 176c3eb73092be7156a56bf154af73a9e9868885..5f770769103d9f085b6d5dca501ad511d4c6f3d2 100644 (file)
@@ -49,6 +49,9 @@ static struct SilcLogStruct silclogs[SILC_LOG_MAX] = {
   {"", NULL, 0, "Fatal", SILC_LOG_FATAL, NULL, NULL},
 };
 
+/* Causes logging output to contain timestamps */
+bool silc_log_timestamp = TRUE;
+
 /* If TRUE, log files will be flushed for each log input */
 bool silc_log_quick = FALSE;
 
@@ -220,7 +223,12 @@ void silc_log_output(SilcLogType type, char *string)
   goto end;
 
  found:
-  fprintf(fp, "[%s] [%s] %s\n", silc_get_time(), typename, string);
+  /* writes the logging string to the selected channel */
+  if (silc_log_timestamp)
+    fprintf(fp, "[%s] [%s] %s\n", silc_get_time(), typename, string);
+  else
+    fprintf(fp, "[%s] %s\n", typename, string);
+
   if (silc_log_quick || silc_log_starting) {
     fflush(fp);
     if (log) /* we may have been redirected to stderr */
@@ -497,6 +505,7 @@ void silc_log_set_debug_string(const char *debug_string)
   len = strlen(string);
   if (len >= sizeof(silc_log_debug_string))
     len = sizeof(silc_log_debug_string) - 1;
+  memset(silc_log_debug_string, 0, sizeof(silc_log_debug_string));
   strncpy(silc_log_debug_string, string, len);
   silc_free(string);
 }