Coverage Report

Created: 2025-11-02 06:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/tinysparql/src/common/tracker-debug.c
Line
Count
Source
1
/*
2
 * Copyright (C) 2020, Sam Thursfield <sam@afuera.me.uk>
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2.1 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.          See the GNU
12
 * Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15
 * License along with this library; if not, write to the
16
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
 * Boston, MA  02110-1301, USA.
18
 */
19
20
#include "config.h"
21
22
#include "tracker-debug.h"
23
24
#ifdef G_ENABLE_DEBUG
25
static const GDebugKey tracker_debug_keys[] = {
26
  { "collation", TRACKER_DEBUG_COLLATION },
27
  { "ontology-changes", TRACKER_DEBUG_ONTOLOGY_CHANGES },
28
  { "sqlite", TRACKER_DEBUG_SQLITE },
29
  { "sparql", TRACKER_DEBUG_SPARQL },
30
  { "sql", TRACKER_DEBUG_SQL },
31
  { "fts-integrity", TRACKER_DEBUG_FTS_INTEGRITY },
32
};
33
#endif /* G_ENABLE_DEBUG */
34
35
static gpointer
36
parse_debug_flags ()
37
1
{
38
1
  const gchar *env_string;
39
1
  guint flags = 0;
40
41
1
  env_string = g_getenv ("TINYSPARQL_DEBUG");
42
1
  if (env_string == NULL)
43
1
    env_string = g_getenv ("TRACKER_DEBUG");
44
45
1
  if (env_string != NULL) {
46
0
#ifdef G_ENABLE_DEBUG
47
0
    flags = g_parse_debug_string (env_string, tracker_debug_keys, G_N_ELEMENTS (tracker_debug_keys));
48
#else
49
    g_warning ("TINYSPARQL_DEBUG set but ignored because tracker isn't built with G_ENABLE_DEBUG");
50
#endif  /* G_ENABLE_DEBUG */
51
0
    env_string = NULL;
52
0
  }
53
54
1
  return GINT_TO_POINTER (flags);
55
1
}
56
57
guint
58
tracker_get_debug_flags (void)
59
4.60M
{
60
4.60M
  static GOnce once = G_ONCE_INIT;
61
62
4.60M
  g_once (&once, parse_debug_flags, NULL);
63
64
4.60M
  return GPOINTER_TO_INT (once.retval);
65
4.60M
}