nautilus/libnautilus-private/nautilus-debug-log.h
Federico Mena Quintero 3b44116754 Use the write-to-a-pipe trick from the signal handler instead of queueing
2006-11-23  Federico Mena Quintero  <federico@novell.com>

	Use the write-to-a-pipe trick from the signal handler instead of
	queueing an idle handler from there.

	* src/nautilus-main.c (setup_debug_log_signals): Set up a pair of
	pipes for the SIGUSR1 handler; set up a GIOChannel on them.
	(sigusr1_handler): Write a byte to our pipe instead of queueing an
	idle handler.
	(debug_log_io_cb): Replaces dump_debug_log_idle_cb().  Read from
	the pipe, and dump the debug log.

	Add a configuration file for the logging mechanism.  You create
	~/nautilus-debug-log.conf as a GKeyFile.

	* libnautilus-private/nautilus-debug-log.c
	(nautilus_debug_log_load_configuration): New function; loads the
	configuration from a key file like this:

		[debug log]
		enable domains = foo; bar; baz
		max lines = 1000

	* libnautilus-private/nautilus-debug-log.c (dump_configuration):
	New utility function.
	(nautilus_debug_log_dump): At the end of the log, dump the
	configuration used for the debug log so that the user can
	re-create it later.

	* libnautilus-private/nautilus-debug-log.h: New prototype for
	nautilus_debug_log_load_configuration().

	* src/nautilus-main.c (setup_debug_log): Load the debug log's
	configuration from ~/nautilus-debug-log.conf
	(setup_debug_log_domains): Removed.

	* src/nautilus-main.c (log_override_cb): If the log level of the
	message is G_LOG_LEVEL_DEBUG, don't log it as a milestone.  We'll
	use this log level for miscellaneous debugging messages from
	gnome-vfs.  Also, don't send G_LOG_LEVEL_DEBUG messages to the
	default log handler, to avoid a huge ~/.xsession-errors.
	(setup_debug_log_domains): Enable logging for
	NAUTILUS_DEBUG_LOG_DOMAIN_GLOG.
2006-11-23 16:26:05 +00:00

59 lines
2.3 KiB
C

/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
nautilus-debug-log.h: Ring buffer for logging debug messages
Copyright (C) 2006 Novell, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Author: Federico Mena-Quintero <federico@novell.com>
*/
#ifndef NAUTILUS_DEBUG_LOG_H
#define NAUTILUS_DEBUG_LOG_H
#include <glib.h>
#define NAUTILUS_DEBUG_LOG_DOMAIN_USER "USER" /* always enabled */
#define NAUTILUS_DEBUG_LOG_DOMAIN_ASYNC "async" /* when asynchronous notifications come in */
#define NAUTILUS_DEBUG_LOG_DOMAIN_GLOG "GLog" /* used for GLog messages; don't use it yourself */
void nautilus_debug_log (gboolean is_milestone, const char *domain, const char *format, ...);
void nautilus_debug_log_with_uri_list (gboolean is_milestone, const char *domain, const GList *uris,
const char *format, ...);
void nautilus_debug_log_with_file_list (gboolean is_milestone, const char *domain, GList *files,
const char *format, ...);
void nautilus_debug_logv (gboolean is_milestone, const char *domain, const GList *uris, const char *format, va_list args);
gboolean nautilus_debug_log_load_configuration (const char *filename, GError **error);
void nautilus_debug_log_enable_domains (const char **domains, int n_domains);
void nautilus_debug_log_disable_domains (const char **domains, int n_domains);
gboolean nautilus_debug_log_is_domain_enabled (const char *domain);
gboolean nautilus_debug_log_dump (const char *filename, GError **error);
void nautilus_debug_log_set_max_lines (int num_lines);
int nautilus_debug_log_get_max_lines (void);
/* For testing only */
void nautilus_debug_log_clear (void);
#endif /* NAUTILUS_DEBUG_LOG_H */