summaryrefslogtreecommitdiff
path: root/src/libtracker-common/tracker-debug.h
blob: c051e980cc10cc9f572199a4b7b8e2ed089a2ba7 (plain)
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
/*
 * 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_COLLATION        = 1 <<  1,
  TRACKER_DEBUG_ONTOLOGY_CHANGES = 1 <<  2,
  TRACKER_DEBUG_SQLITE           = 1 <<  3,
  TRACKER_DEBUG_SQL_STATEMENTS   = 1 <<  4,
} 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__ */