[Gnucash-changes] r13117 - gnucash/trunk - Deprecating
qof_log_set_level_global in favour of qof_log_set_level_registered.
Neil Williams
codehelp at cvs.gnucash.org
Sun Feb 5 07:25:46 EST 2006
Author: codehelp
Date: 2006-02-05 07:25:45 -0500 (Sun, 05 Feb 2006)
New Revision: 13117
Trac: http://svn.gnucash.org/trac/changeset/13117
Modified:
gnucash/trunk/ChangeLog
gnucash/trunk/lib/libqof/qof/deprecated.c
gnucash/trunk/lib/libqof/qof/deprecated.h
gnucash/trunk/lib/libqof/qof/qoflog.c
gnucash/trunk/lib/libqof/qof/qoflog.h
Log:
Deprecating qof_log_set_level_global in favour of qof_log_set_level_registered.
Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog 2006-02-05 10:58:38 UTC (rev 13116)
+++ gnucash/trunk/ChangeLog 2006-02-05 12:25:45 UTC (rev 13117)
@@ -1,5 +1,15 @@
2006-02-05 Neil Williams <linux at codehelp.co.uk>
+ * lib/libqof/qof/qoflog.c :
+ * lib/libqof/qof/qoflog.h :
+ * lib/libqof/qof/deprecated.c :
+ * lib/libqof/qof/deprecated.h : Deprecating qof_log_set_level_global
+ in favour of qof_log_set_level_registered. Documenting circumstances
+ under which _global could be modified and added as a new function.
+ Improve qof_log_check to handle out-of-bounds log_levels.
+
+2006-02-05 Neil Williams <linux at codehelp.co.uk>
+
* lib/libqof/qof/qofbackend-p.h :
* lib/libqof/qof/qofbackend.h : Improving
documentation for QofBackendProvider
Modified: gnucash/trunk/lib/libqof/qof/deprecated.c
===================================================================
--- gnucash/trunk/lib/libqof/qof/deprecated.c 2006-02-05 10:58:38 UTC (rev 13116)
+++ gnucash/trunk/lib/libqof/qof/deprecated.c 2006-02-05 12:25:45 UTC (rev 13117)
@@ -35,8 +35,12 @@
}
void gnc_set_log_level_global(gncLogLevel level)
{
- qof_log_set_level_global((QofLogLevel)level);
+ qof_log_set_level_registered((QofLogLevel)level);
}
+void qof_log_set_level_global(QofLogLevel level)
+{
+ qof_log_set_level_registered((QofLogLevel)level);
+}
void gnc_set_logfile (FILE *outfile)
{
qof_log_set_file(outfile);
Modified: gnucash/trunk/lib/libqof/qof/deprecated.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/deprecated.h 2006-02-05 10:58:38 UTC (rev 13116)
+++ gnucash/trunk/lib/libqof/qof/deprecated.h 2006-02-05 12:25:45 UTC (rev 13117)
@@ -38,9 +38,23 @@
/** \deprecated use qof_log_set_level insead. */
void gnc_set_log_level(QofLogModule module, gncLogLevel level);
-/** \deprecated use qof_log_set_level_global instead. */
+/** \deprecated use qof_log_set_level_registered instead. */
void gnc_set_log_level_global(gncLogLevel level);
+/** \deprecated use qof_log_set_level_registered instead.
+
+This function has been deprecated because the function name
+is very misleading. It may, in future, be modified to be
+truly global (i.e. make changes to log modules where no
+log_level has been explicitly set) but, despite the name,
+it only ever modified known (gnucash) modules. Future changes
+would require that if this function is made truly global it must
+preserve the effect of qof_log_set_level_registered and the advantages
+of silent log_modules for those programs that do not use _global. Support
+could be required for removing log_modules from the hashtable.
+*/
+void qof_log_set_level_global(QofLogLevel level);
+
/** \deprecated use qof_log_set_file instead. */
void gnc_set_logfile (FILE *outfile);
Modified: gnucash/trunk/lib/libqof/qof/qoflog.c
===================================================================
--- gnucash/trunk/lib/libqof/qof/qoflog.c 2006-02-05 10:58:38 UTC (rev 13116)
+++ gnucash/trunk/lib/libqof/qof/qoflog.c 2006-02-05 12:25:45 UTC (rev 13117)
@@ -2,7 +2,7 @@
* qoflog.c
*
* Mon Nov 21 14:41:59 2005
- * Author: Rob Clark (rclark at cs.hmc.edu) *
+ * Author: Rob Clark (rclark at cs.hmc.edu)
* Copyright (C) 1997-2003 Linas Vepstas <linas at linas.org>
* Copyright 2005 Neil Williams
* linux at codehelp.co.uk
@@ -70,11 +70,8 @@
void
qof_log_drop_indent(void)
{
- qof_log_num_spaces -= QOF_LOG_INDENT_WIDTH;
- if(qof_log_num_spaces < 0)
- {
- qof_log_num_spaces = 0;
- }
+ qof_log_num_spaces = (qof_log_num_spaces < QOF_LOG_INDENT_WIDTH) ?
+ 0 : qof_log_num_spaces - QOF_LOG_INDENT_WIDTH;
}
static void
@@ -96,7 +93,7 @@
fout = fopen ("/tmp/qof.trace", "w");
}
- if(!fout && (filename = (char *)g_malloc(MAX_TRACE_FILENAME))) {
+ if(!fout && (filename = (gchar *)g_malloc(MAX_TRACE_FILENAME))) {
snprintf(filename, MAX_TRACE_FILENAME-1, "/tmp/qof.trace.%d",
getpid());
fout = fopen (filename, "w");
@@ -130,7 +127,7 @@
}
void
-qof_log_set_level_global(QofLogLevel level)
+qof_log_set_level_registered(QofLogLevel level)
{
gchar* level_string;
@@ -173,7 +170,7 @@
const char *
qof_log_prettify (const char *name)
{
- char *p, *buffer;
+ gchar *p, *buffer;
gint length;
if (!name) { return ""; }
@@ -205,7 +202,7 @@
void
qof_start_clock (int clockno, QofLogModule log_module, QofLogLevel log_level,
- const char *function_name, const char *format, ...)
+ const gchar *function_name, const gchar *format, ...)
{
struct timezone tz;
va_list ap;
@@ -229,8 +226,8 @@
}
void
-qof_report_clock (int clockno, QofLogModule log_module, QofLogLevel log_level,
- const char *function_name, const char *format, ...)
+qof_report_clock (gint clockno, QofLogModule log_module, QofLogLevel log_level,
+ const gchar *function_name, const gchar *format, ...)
{
struct timezone tz;
struct timeval now;
@@ -268,9 +265,9 @@
}
void
-qof_report_clock_total (int clockno,
+qof_report_clock_total (gint clockno,
QofLogModule log_module, QofLogLevel log_level,
- const char *function_name, const char *format, ...)
+ const gchar *function_name, const gchar *format, ...)
{
va_list ap;
@@ -305,10 +302,11 @@
qof_log_check(QofLogModule log_module, QofLogLevel log_level)
{
gchar* log_string;
- QofLogLevel maximum; /* Any log_level less than this will be logged. */
+ QofLogLevel maximum; /* Any positive log_level less than this will be logged. */
log_string = NULL;
- if(!log_table || log_module == NULL || log_level == 0) { return FALSE; }
+ if (log_level > QOF_LOG_TRACE) log_level = QOF_LOG_TRACE;
+ if(!log_table || log_module == NULL || log_level < 0) { return FALSE; }
log_string = (gchar*)g_hash_table_lookup(log_table, log_module);
/* if log_module not found, do not log. */
if(!log_string) { return FALSE; }
Modified: gnucash/trunk/lib/libqof/qof/qoflog.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qoflog.h 2006-02-05 10:58:38 UTC (rev 13116)
+++ gnucash/trunk/lib/libqof/qof/qoflog.h 2006-02-05 12:25:45 UTC (rev 13117)
@@ -2,7 +2,7 @@
* qof-log.h
*
* Mon Nov 21 14:35:26 2005
- * Author: Rob Clark (rclark at cs.hmc.edu) *
+ * Author: Rob Clark (rclark at cs.hmc.edu)
* Copyright (C) 1998-2003 Linas Vepstas <linas at linas.org>
* Copyright 2005 Neil Williams
* linux at codehelp.co.uk
@@ -89,16 +89,34 @@
*/
void qof_log_init (void);
-/** Set the logging level of the given log_module. */
+/** Set the logging level of the given log_module.
+
+Registers the log_module with the qof_log hashtable and
+sets an initial value for the loglevel for that log_module.
+*/
void qof_log_set_level(QofLogModule module, QofLogLevel level);
-/** Set the logging level for all known log_modules.
+/** Set the logging level for all registered log_modules.
\note Unless a log_module has been registered using
-qof_log_set_level, it will be unaffected by this change.
+qof_log_set_level, it will be unaffected by this change because
+there will be no entry in the hashtable.
+"silent" log_modules are supported by the qof_log_set_level_registered
+function which only moderates log_levels for those modules actually
+registered. The advantage is that a developer can omit existing
+log_modules from the init code and cut down the amount of unwanted logging.
+
+e.g. if you are working in one section of the code and do not want
+the extra log information created by allowing the default modules
+to log as well. This makes the log itself easier to use when working
+in a small area of the codebase. Silent log_modules can also be
+useful where no default currently exists - again to isolate certain
+sections of the default log output - and using qof_log_set_level_registered
+allows these silent log_modules to be retained in the code without
+being logged by other developers etc.
*/
-void qof_log_set_level_global(QofLogLevel level);
+void qof_log_set_level_registered(QofLogLevel level);
/** Specify an alternate log output, to pipe or file.
By default, all logging goes to /tmp/qof.trace
More information about the gnucash-changes
mailing list