4
* Copyright 2010 Canonical Ltd.
6
* This library is free software; you can redistribute it and/or modify it under
7
* the terms of the GNU Lesser General Public License as published by the Free
8
* Software Foundation; either version 3 of the License, or (at your option) any
11
* This library is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this program; if not, write to the Free Software Foundation, Inc.,
18
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#include "geis_logging.h"
28
static const char *prefix_format = "GEIS(%s)-%s:%d ";
29
static const char *debug_marker = "debug";
30
static const char *warning_marker = "warning";
31
static const char *error_marker = "error";
37
char *level = getenv("GEIS_DEBUG");
46
level_is_enabled(int desired_level)
48
static int level = -1;
50
level = reporting_level();
51
return level >= desired_level;
56
_geis_message(int level, const char* function, int line, const char *format, ...)
59
if (level_is_enabled(level))
61
const char *marker = NULL;
64
case _GEIS_LOG_LEVEL_DEBUG:
65
marker = debug_marker;
67
case _GEIS_LOG_LEVEL_WARNING:
68
marker = warning_marker;
71
marker = error_marker;
75
fprintf(stderr, prefix_format, marker, function, line);
79
count = vfprintf(stderr, format, ap);
82
fprintf(stderr, "\n");