/usr/include/gnucash/qoflog.h is in gnucash-common 1:2.6.15-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | /* qof-log.h
* Author: Rob Clark <rclark@cs.hmc.edu>
* Copyright (C) 1998-2003 Linas Vepstas <linas@linas.org>
* Copyright 2005 Neil Williams <linux@codehelp.co.uk>
* Copyright 2007 Joshua Sled <jsled@asynchronous.org>
*/
/*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/
/**
* @addtogroup Logging
* @{
* @ingroup QOF
* @brief Logging and tracing facility.
* @sa "Logging overhaul" announcement <http://lists.gnucash.org/pipermail/gnucash-devel/2007-February/019836.html>
*
* qof_log_init(void) installs a handler that interprets the "log_domain"
* as a "."-separated path. Log level thresholds can be set for each level
* in the tree. When a message is logged, the longest level match is
* found, and used as the threshold.
*
* For instance, we can set the levels as such:
* @verbatim
"qof" = WARN
"gnc" = WARN
"gnc.ui" = INFO
"gnc.ui.plugin-page.sx-list" = DEBUG
@endverbatim
*
* When code in the log_module of "gnc.import" attempts to log at DEBUG
* (let's say), the handler will attempt to match the log domain to
* successively-longer paths: first "", then "gnc", then "gnc.import". Given
* the settings above, the path "gnc" will match -- at a level of "WARN" --
* and the DEBUG-level log will be rejected. When code in the log domain of
* "gnc.ui.plugin-page.sx-list" logs at DEBUG, however, it will match at
* DEBUG, and be allowed.
*
* The current log format is as above:
*
* @verbatim
* [timestamp] [level] <[log-domain]> [message]
@endverbatim
*
* The timestamp and level are constant width (level is 5 characters). The
* log domain is re-iterated, which gives some context, but could become
* annoying if they get long.
*
* Trailing newlines (e.g. <tt>PINFO("...\n", ...)</tt>) are removed; the logger
* will newline separate output.
*
* @section best Best Practices
*
* Code should:
*
* @li Define both <tt>static QofLogModule log_module</tt> and <tt>#define
* G_LOG_DOMAIN</tt> to the same value.
* @li Define a logical, specific path as the log domain;
* @c "gnc.gui.plugin-pages.sx-list" or
* @c "gnc.register.gnome.cell.quickfill" are
* good examples.
* @li Use glib-provided @c g_debug(...), @c g_message(...),
* @c g_warning(...), @c g_critical(...) and
* @c g_error(...) functions in preference to the historical qof/gnc @c
* PINFO, @c PERR (&c.) macros
*
* @see qof_log_parse_log_config(const char*)
**/
#ifndef _QOF_LOG_H
#define _QOF_LOG_H
#include <stdarg.h>
#include <stdio.h>
#include <glib.h>
#include "qofutil.h"
#define QOF_MOD_ENGINE "qof.engine"
#define LOG_LEVEL_LIST(_) \
_(QOF_LOG_FATAL, = G_LOG_LEVEL_ERROR) \
_(QOF_LOG_ERROR, = G_LOG_LEVEL_CRITICAL) \
_(QOF_LOG_WARNING, = G_LOG_LEVEL_WARNING) \
_(QOF_LOG_MESSAGE, = G_LOG_LEVEL_MESSAGE) \
_(QOF_LOG_INFO, = G_LOG_LEVEL_INFO) \
_(QOF_LOG_DEBUG, = G_LOG_LEVEL_DEBUG)
DEFINE_ENUM (QofLogLevel, LOG_LEVEL_LIST)
gchar* qof_log_level_to_string(QofLogLevel lvl);
QofLogLevel qof_log_level_from_string(const gchar *str);
/** Indents one level; see ENTER macro. **/
void qof_log_indent(void);
/**
* De-dent one level, capped at 0; see LEAVE macro.
**/
void qof_log_dedent(void);
/**
* Initialize the error logging subsystem. Defaults to a level-threshold of
* "warning", and logging to stderr.
**/
void qof_log_init (void);
/** Set the logging level of the given log_module. **/
void qof_log_set_level(QofLogModule module, QofLogLevel level);
/** Specify an alternate log output, to pipe or file. **/
void qof_log_set_file (FILE *outfile);
/** Specify a filename for log output. **/
void qof_log_init_filename (const gchar* logfilename);
/**
* If @a log_to_filename is "stderr" or "stdout" (exactly,
* case-insensitive), then those special files are used; otherwise, the
* literal filename as given, as qof_log_init_filename(gchar*)
**/
void qof_log_init_filename_special(const char *log_to_filename);
/**
* Parse a log-configuration file. A GKeyFile-format file of the schema:
* @verbatim
[levels]
# log.ger.path=level
gnc.engine.sx=debug
gnc.gui.sx=debug
gnc.import-export.qif.parse=debug
[output]
# to=["stderr"|"stdout"|filename]
to=stderr
@endverbatim
**/
void qof_log_parse_log_config(const char *filename);
/** Be nice, close the logfile if possible. */
void qof_log_shutdown (void);
/**
* Cleans up subroutine names. AIX/xlC has the habit of printing signatures
* not names; clean this up. On other operating systems, truncate name to
* QOF_LOG_MAX_CHARS chars.
**/
const gchar * qof_log_prettify (const gchar *name);
/** Check to see if the given @a log_module is configured to log at the given
* @a log_level. This implements the "log.path.hierarchy" logic. **/
gboolean qof_log_check(QofLogModule log_module, QofLogLevel log_level);
/** Set the default level for QOF-related log paths. **/
void qof_log_set_default(QofLogLevel log_level);
#define PRETTY_FUNC_NAME qof_log_prettify(G_STRFUNC)
#ifdef _MSC_VER
/* Microsoft Visual Studio: MSVC compiler has a different syntax for
* macros with variadic argument list. */
/** Log a fatal error */
#define FATAL(format, ...) do { \
g_log (log_module, G_LOG_LEVEL_ERROR, \
"[%s()] " format, PRETTY_FUNC_NAME , __VA_ARGS__); \
} while (0)
/** Log a serious error */
#define PERR(format, ...) do { \
g_log (log_module, G_LOG_LEVEL_CRITICAL, \
"[%s()] " format, PRETTY_FUNC_NAME , __VA_ARGS__); \
} while (0)
/** Log a warning */
#define PWARN(format, ...) do { \
g_log (log_module, G_LOG_LEVEL_WARNING, \
"[%s()] " format, PRETTY_FUNC_NAME , __VA_ARGS__); \
} while (0)
/** Print an informational note */
#define PINFO(format, ...) do { \
g_log (log_module, G_LOG_LEVEL_INFO, \
"[%s] " format, PRETTY_FUNC_NAME , __VA_ARGS__); \
} while (0)
/** Print a debugging message */
#define DEBUG(format, ...) do { \
g_log (log_module, G_LOG_LEVEL_DEBUG, \
"[%s] " format, PRETTY_FUNC_NAME , __VA_ARGS__); \
} while (0)
/** Print a function entry debugging message */
#define ENTER(format, ...) do { \
if (qof_log_check(log_module, (QofLogLevel)G_LOG_LEVEL_DEBUG)) { \
g_log (log_module, G_LOG_LEVEL_DEBUG, \
"[enter %s:%s()] " format, __FILE__, \
PRETTY_FUNC_NAME , __VA_ARGS__); \
qof_log_indent(); \
} \
} while (0)
/** Print a function exit debugging message. **/
#define LEAVE(format, ...) do { \
if (qof_log_check(log_module, (QofLogLevel)G_LOG_LEVEL_DEBUG)) { \
qof_log_dedent(); \
g_log (log_module, G_LOG_LEVEL_DEBUG, \
"[leave %s()] " format, \
PRETTY_FUNC_NAME , __VA_ARGS__); \
} \
} while (0)
#else /* _MSC_VER */
/** Log a fatal error */
#define FATAL(format, args...) do { \
g_log (log_module, G_LOG_LEVEL_ERROR, \
"[%s()] " format, PRETTY_FUNC_NAME , ## args); \
} while (0)
/** Log a serious error */
#define PERR(format, args...) do { \
g_log (log_module, G_LOG_LEVEL_CRITICAL, \
"[%s()] " format, PRETTY_FUNC_NAME , ## args); \
} while (0)
/** Log a warning */
#define PWARN(format, args...) do { \
g_log (log_module, G_LOG_LEVEL_WARNING, \
"[%s()] " format, PRETTY_FUNC_NAME , ## args); \
} while (0)
/** Print an informational note */
#define PINFO(format, args...) do { \
g_log (log_module, G_LOG_LEVEL_INFO, \
"[%s] " format, PRETTY_FUNC_NAME , ## args); \
} while (0)
/** Print a debugging message */
#define DEBUG(format, args...) do { \
g_log (log_module, G_LOG_LEVEL_DEBUG, \
"[%s] " format, PRETTY_FUNC_NAME , ## args); \
} while (0)
/** Print a function entry debugging message */
#define ENTER(format, args...) do { \
if (qof_log_check(log_module, (QofLogLevel)G_LOG_LEVEL_DEBUG)) { \
g_log (log_module, G_LOG_LEVEL_DEBUG, \
"[enter %s:%s()] " format, __FILE__, \
PRETTY_FUNC_NAME , ## args); \
qof_log_indent(); \
} \
} while (0)
/** Print a function exit debugging message. **/
#define LEAVE(format, args...) do { \
if (qof_log_check(log_module, (QofLogLevel)G_LOG_LEVEL_DEBUG)) { \
qof_log_dedent(); \
g_log (log_module, G_LOG_LEVEL_DEBUG, \
"[leave %s()] " format, \
PRETTY_FUNC_NAME , ## args); \
} \
} while (0)
#endif /* _MSC_VER */
/** Replacement for @c g_return_val_if_fail, but calls LEAVE if the test fails. **/
#define gnc_leave_return_val_if_fail(test, val) do { \
if (! (test)) { LEAVE(""); } \
g_return_val_if_fail(test, val); \
} while (0);
/** Replacement for @c g_return_if_fail, but calls LEAVE if the test fails. **/
#define gnc_leave_return_if_fail(test) do { \
if (! (test)) { LEAVE(""); } \
g_return_if_fail(test); \
} while (0);
#endif /* _QOF_LOG_H */
/** @} */
|