~oif-team/geis/geis2-add-device

« back to all changes in this revision

Viewing changes to libutouch-geis-xcb/geis_logging.h

  • Committer: Stephen M. Webb
  • Date: 2010-09-01 18:49:00 UTC
  • mfrom: (74.1.3 geis-logging)
  • Revision ID: stephen.webb@canonical.com-20100901184900-f5k5ohe4kg010sb9
Added improved runtime-configurable diagnostics.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * @file geis_logging.h
 
3
 * @brief internal GEIS debug/logging facilities
 
4
 *
 
5
 * Copyright 2010 Canonical Ltd.
 
6
 *
 
7
 * This library is free software; you can redistribute it and/or modify it under
 
8
 * the terms of the GNU Lesser General Public License as published by the Free
 
9
 * Software Foundation; either version 3 of the License, or (at your option) any
 
10
 * later version.
 
11
 *
 
12
 * This library is distributed in the hope that it will be useful, but WITHOUT
 
13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
14
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 
15
 * details.
 
16
 *
 
17
 * You should have received a copy of the GNU Lesser General Public License
 
18
 * along with this program; if not, write to the Free Software Foundation, Inc.,
 
19
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
20
 */
 
21
#ifndef GEIS_LOGGING_H_
 
22
#define GEIS_LOGGING_H_
 
23
 
 
24
/**
 
25
 * @defgroup geis_logging GEIS Logging Facilities
 
26
 *
 
27
 * This facility allows the run-time delivery of debugging and error emssages
 
28
 * from the library.  By default, no debug or error diagnostics are emitted by
 
29
 * the library.  However, if the environment variable GEIS_DEBUG is set to an
 
30
 * appropriate value, these diagnostic messages will be emitted to stderr.
 
31
 *
 
32
 * The following GEIS_DEBUG values are supported.
 
33
 *
 
34
 * GEIS_DEBUG=1  error messages only are emitted
 
35
 * GEIS_DEBUG=2  error and warning messages are emitted
 
36
 * GEIS_DEBUG=3  error, warning, and debug messages are emitted
 
37
 *
 
38
 * @{
 
39
 */
 
40
 
 
41
#define _GEIS_LOG_LEVEL_ERROR    1
 
42
#define _GEIS_LOG_LEVEL_WARNING  2
 
43
#define _GEIS_LOG_LEVEL_DEBUG    3
 
44
 
 
45
/**
 
46
 * Emits a message at the DEBUG logging level.
 
47
 * @param[in] fmt printf-style format string
 
48
 */
 
49
#define geis_debug(...) _geis_message(_GEIS_LOG_LEVEL_DEBUG, \
 
50
                                      __FUNCTION__, __LINE__, \
 
51
                                      __VA_ARGS__)
 
52
#define geis_warning(...) _geis_message(_GEIS_LOG_LEVEL_WARNING, \
 
53
                                        __FUNCTION__, __LINE__, \
 
54
                                        __VA_ARGS__)
 
55
#define geis_error(...) _geis_message(_GEIS_LOG_LEVEL_ERROR, \
 
56
                                      __FUNCTION__, __LINE__, \
 
57
                                      __VA_ARGS__)
 
58
int _geis_message(int level,
 
59
                  const char *function, int line,
 
60
                  const char *format, ...) __attribute__((format(printf, 4, 5)));
 
61
 
 
62
/* @} */
 
63
 
 
64
#endif /* GEIS_LOGGING_H_ */