[Freeswitch-trunk] [commit] r6517 - freeswitch/trunk/src/mod/loggers/mod_logfile

Freeswitch SVN mikej at freeswitch.org
Wed Dec 5 08:15:22 EST 2007


Author: mikej
Date: Wed Dec  5 08:15:21 2007
New Revision: 6517

Modified:
   freeswitch/trunk/src/mod/loggers/mod_logfile/mod_logfile.c

Log:
another step towards multi-profile file logger.

Modified: freeswitch/trunk/src/mod/loggers/mod_logfile/mod_logfile.c
==============================================================================
--- freeswitch/trunk/src/mod/loggers/mod_logfile/mod_logfile.c	(original)
+++ freeswitch/trunk/src/mod/loggers/mod_logfile/mod_logfile.c	Wed Dec  5 08:15:21 2007
@@ -297,16 +297,26 @@
 static void event_handler(switch_event_t *event)
 {
 	const char *sig = switch_event_get_header(event, "Trapped-Signal");
+    switch_hash_index_t *hi;
+	void *val;
+	const void *var;
+	logfile_profile_t *profile;
 
 	if (sig && !strcmp(sig, "HUP")) {
 		if (globals.rotate) {
-			/* TODO: loop through all profiles */
-			mod_logfile_rotate(default_profile);
+		    for (hi = switch_hash_first(NULL, profile_hash); hi; hi = switch_hash_next(hi)) {
+		        switch_hash_this(hi, &var, NULL, &val);
+				profile = val;
+				mod_logfile_rotate(profile);
+			}
 		} else {
 			switch_mutex_lock(globals.mutex);
-			/* TODO: loop through all profiles */
-			switch_file_close(default_profile->log_afd);
-			mod_logfile_openlogfile(default_profile, SWITCH_TRUE);
+		    for (hi = switch_hash_first(NULL, profile_hash); hi; hi = switch_hash_next(hi)) {
+		        switch_hash_this(hi, &var, NULL, &val);
+				profile = val;
+				switch_file_close(profile->log_afd);
+				mod_logfile_openlogfile(profile, SWITCH_TRUE);
+			}
 			switch_mutex_unlock(globals.mutex);
 		}
 	}
@@ -362,11 +372,14 @@
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Settings, check the new config!\n");
 				} else {
 					logfile_profile_t *profile;
-					profile = switch_core_alloc(module_pool, sizeof(*default_profile));
+					profile = switch_core_alloc(module_pool, sizeof(*profile));
 					memset(profile, 0, sizeof(*profile));
 					profile->name = switch_core_strdup(module_pool, switch_str_nil(name));
 					load_profile(profile, settings);
 					switch_core_hash_insert(profile_hash, profile->name, (void *) profile);
+					if (mod_logfile_openlogfile(profile, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) {
+						return SWITCH_STATUS_GENERR;
+					}
 					/* TODO: remove default_profile */
 					default_profile = profile;
 				}
@@ -376,11 +389,6 @@
 		switch_xml_free(xml);
 	}
 
-	/* TODO: do this for all profiles */
-	if (mod_logfile_openlogfile(default_profile, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) {
-		return SWITCH_STATUS_GENERR;
-	}
-
 	switch_log_bind_logger(mod_logfile_logger, SWITCH_LOG_DEBUG);
 
 	return SWITCH_STATUS_SUCCESS;



More information about the Freeswitch-trunk mailing list