Revision f82a8605 log.c

View differences:

log.c
31 31
#define BUFFER_ALLOCSZ(r)	(r + sizeof(janus_log_buffer))
32 32

  
33 33
static gboolean janus_log_console = TRUE;
34
static char *janus_log_filepath = NULL;
34 35
static FILE *janus_log_file = NULL;
35 36

  
36 37
static gint initialized = 0;
......
47 48
static janus_log_buffer *bufferpool = NULL;
48 49

  
49 50

  
51
gboolean janus_log_is_stdout_enabled(void) {
52
	return janus_log_console;
53
}
54

  
55
gboolean janus_log_is_logfile_enabled(void) {
56
	return janus_log_file != NULL;
57
}
58

  
59
char *janus_log_get_logfile_path(void) {
60
	return janus_log_filepath;
61
}
62

  
63

  
50 64
static void janus_log_freebuffers(janus_log_buffer **list) {
51 65
	janus_log_buffer *b, *head = *list;
52 66

  
......
150 164
	if(janus_log_file)
151 165
		fclose(janus_log_file);
152 166
	janus_log_file = NULL;
167
	if(janus_log_filepath)
168
		g_free(janus_log_filepath);
169
	janus_log_filepath = NULL;
153 170

  
154 171
	return NULL;
155 172
}
......
200 217
			g_print("Error opening log file %s: %s\n", logfile, strerror(errno));
201 218
			return -1;
202 219
		}
220
		janus_log_filepath = g_strdup(logfile);
221
	}
222
	if(!janus_log_console && logfile == NULL) {
223
		g_print("WARNING: logging completely disabled!\n");
224
		g_print("         (no stdout and no logfile, this may not be what you want...)\n");
203 225
	}
204 226
	printthread = g_thread_new(THREAD_NAME, &janus_log_thread, NULL);
205 227
	return 0;

Also available in: Unified diff