diff options
author | Sam Thursfield <sam@afuera.me.uk> | 2020-04-20 00:29:47 +0200 |
---|---|---|
committer | Sam Thursfield <sam@afuera.me.uk> | 2020-04-20 01:42:34 +0200 |
commit | ca1a0f3c28fdbc3dae2c7bd6019fdcacb021e610 (patch) | |
tree | 3a8c102969cde7182d6fd9566287021af97eac09 /src/libtracker-common/tracker-debug.h | |
parent | 9bb96a716581371e3229f036136234af476fc82b (diff) | |
download | tracker-ca1a0f3c28fdbc3dae2c7bd6019fdcacb021e610.tar.gz |
Add TRACKER_DEBUG environment variable, use for SQL debug
This works the same as GTK's GTK_DEBUG variable. It will
allow us to include more types of optional debugging info,
and will make the default debug output more readlable.
See https://gitlab.gnome.org/GNOME/tracker/issues/178
Diffstat (limited to 'src/libtracker-common/tracker-debug.h')
-rw-r--r-- | src/libtracker-common/tracker-debug.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/libtracker-common/tracker-debug.h b/src/libtracker-common/tracker-debug.h new file mode 100644 index 000000000..aaca4fc07 --- /dev/null +++ b/src/libtracker-common/tracker-debug.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2020, Sam Thursfield <sam@afuera.me.uk> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __TRACKER_DEBUG_H__ +#define __TRACKER_DEBUG_H__ + +#if !defined (__LIBTRACKER_COMMON_INSIDE__) && !defined (TRACKER_COMPILATION) +#error "only <libtracker-common/tracker-common.h> must be included directly." +#endif + +#include <glib.h> + +G_BEGIN_DECLS + +typedef enum { + TRACKER_DEBUG_SQL_STATEMENTS = 1 << 1, +} TrackerDebugFlag; + +#ifdef G_ENABLE_DEBUG + +#define TRACKER_DEBUG_CHECK(type) G_UNLIKELY (tracker_get_debug_flags () & TRACKER_DEBUG_##type) + +#define TRACKER_NOTE(type,action) G_STMT_START { \ + if (TRACKER_DEBUG_CHECK (type)) \ + { action; }; } G_STMT_END + +#else /* !G_ENABLE_DEBUG */ + +#define TRACKER_DEBUG_CHECK(type) 0 +#define TRACKER_NOTE(type, action) + +#endif /* G_ENABLE_DEBUG */ + +guint tracker_get_debug_flags (void); + +G_END_DECLS + +#endif /* __TRACKER_DEBUG_H__ */ |