Tizen 2.0 Release
[framework/connectivity/neard.git] / include / log.h
1 /*
2  *
3  *  neard - Near Field Communication manager
4  *
5  *  Copyright (C) 2011  Intel Corporation. All rights reserved.
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 2 as
9  *  published by the Free Software Foundation.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21
22 void near_info(const char *format, ...)
23                                 __attribute__((format(printf, 1, 2)));
24 void near_warn(const char *format, ...)
25                                 __attribute__((format(printf, 1, 2)));
26 void near_error(const char *format, ...)
27                                 __attribute__((format(printf, 1, 2)));
28 void near_debug(const char *format, ...)
29                                 __attribute__((format(printf, 1, 2)));
30
31 struct near_debug_desc {
32         const char *name;
33         const char *file;
34 #define NEAR_DEBUG_FLAG_DEFAULT (0)
35 #define NEAR_DEBUG_FLAG_PRINT   (1 << 0)
36         unsigned int flags;
37 } __attribute__((aligned(8)));
38
39 #define DBG(fmt, arg...) do { \
40         static struct near_debug_desc __near_debug_desc \
41         __attribute__((used, section("__debug"), aligned(8))) = { \
42                 .file = __FILE__, .flags = NEAR_DEBUG_FLAG_DEFAULT, \
43         }; \
44         if (__near_debug_desc.flags & NEAR_DEBUG_FLAG_PRINT) \
45                 near_debug("%s:%s() " fmt, \
46                                         __FILE__, __FUNCTION__ , ## arg); \
47 } while (0)