[Freeswitch-branches] [commit] r5028 - freeswitch/branches/anthonyl/fs-branch/src/mod/loggers/mod_log2file

Freeswitch SVN anthonyl at freeswitch.org
Fri Apr 27 13:35:19 EDT 2007


Author: anthonyl
Date: Fri Apr 27 13:35:19 2007
New Revision: 5028

Modified:
   freeswitch/branches/anthonyl/fs-branch/src/mod/loggers/mod_log2file/mod_log2file.c

Log:
yoinked some of the level setting code from mod_console thanks tony!


Modified: freeswitch/branches/anthonyl/fs-branch/src/mod/loggers/mod_log2file/mod_log2file.c
==============================================================================
--- freeswitch/branches/anthonyl/fs-branch/src/mod/loggers/mod_log2file/mod_log2file.c	(original)
+++ freeswitch/branches/anthonyl/fs-branch/src/mod/loggers/mod_log2file/mod_log2file.c	Fri Apr 27 13:35:19 2007
@@ -17,7 +17,7 @@
  * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
  *
  * The Initial Developer of the Original Code is
- * Anthony LaMantia <anthony at petabit.net>
+ * Anthony Minessale II <anthmct at yahoo.com>
  * Portions created by the Initial Developer are Copyright (C)
  * the Initial Developer. All Rights Reserved.
  *
@@ -45,6 +45,11 @@
 static switch_status_t load_config(void);
 static switch_status_t mod_log2file_check(void);
 
+static switch_memory_pool_t *module_pool = NULL;
+static switch_hash_t *log_hash = NULL;
+static switch_hash_t *name_hash = NULL;
+static int8_t all_level = -1;
+
 static struct {
     unsigned int log_fd;
     unsigned int log_size;   /* keep the log size in check for rotation */
@@ -68,6 +73,32 @@
 	/*.directory_interface */ NULL
 };
 
+static void del_mapping(char *var) {
+	if (!strcasecmp(var, "all")) {
+		all_level = -1;
+		return;
+	}
+	switch_core_hash_insert(log_hash, var, NULL);
+}
+
+static void add_mapping(char *var, char *val)
+{
+	char *name;
+
+	if (!strcasecmp(var, "all")) {
+		all_level = (int8_t) switch_log_str2level(val);
+		return;
+	}
+
+	if (!(name = switch_core_hash_find(name_hash, var))) {
+		name = switch_core_strdup(module_pool, var);
+		switch_core_hash_insert(name_hash, name, name);
+	}
+
+	del_mapping(name);
+	switch_core_hash_insert(log_hash, name, (void *) &STATIC_LEVELS[(uint8_t)switch_log_str2level(val)]);
+}
+
 static switch_status_t mod_log2file_openlogfile(void)
 {
     int fd;
@@ -123,7 +154,9 @@
     } while(ret);
 
     ret = fseek(globals.log_fd, 0, SEEK_SET);
-   
+    
+    fclose(fd);
+    
     free(p);
     free(q);
     return SWITCH_STATUS_SUCCESS;
@@ -183,6 +216,7 @@
     if (!message) {
         return SWITCH_STATUS_FALSE;
     }
+    
 	switch_copy_string(message, globals.format, strlen(globals.format)+1);
    
     message = switch_string_replace(message, "${data}", node->data);



More information about the Freeswitch-branches mailing list