Remove WPA2 and WPA3 service together
[platform/upstream/connman.git] / include / log.h
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-2013  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 #ifndef __CONNMAN_LOG_H
23 #define __CONNMAN_LOG_H
24
25 #if defined TIZEN_EXT
26 #include <stdbool.h>
27 #endif
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 /**
34  * SECTION:log
35  * @title: Logging premitives
36  * @short_description: Functions for logging error and debug information
37  */
38
39 void connman_info(const char *format, ...)
40                                 __attribute__((format(printf, 1, 2)));
41 void connman_warn(const char *format, ...)
42                                 __attribute__((format(printf, 1, 2)));
43 void connman_error(const char *format, ...)
44                                 __attribute__((format(printf, 1, 2)));
45 void connman_debug(const char *format, ...)
46                                 __attribute__((format(printf, 1, 2)));
47
48 #define connman_warn_once(fmt, arg...) do {             \
49         static bool printed;                            \
50         if (!printed) {                                 \
51                 connman_warn(fmt, ## arg);              \
52                 printed = true;                         \
53         }                                               \
54 } while (0)
55
56 struct connman_debug_desc {
57         const char *name;
58         const char *file;
59 #if defined TIZEN_EXT
60 #define CONNMAN_DEBUG_FLAG_DEFAULT (1)
61 #else
62 #define CONNMAN_DEBUG_FLAG_DEFAULT (0)
63 #endif
64 #define CONNMAN_DEBUG_FLAG_PRINT   (1 << 0)
65 #define CONNMAN_DEBUG_FLAG_ALIAS   (1 << 1)
66         unsigned int flags;
67 } __attribute__((aligned(8)));
68
69 #define CONNMAN_DEBUG_DEFINE(name) \
70         static struct connman_debug_desc __debug_alias_ ## name \
71         __attribute__((used, section("__debug"), aligned(8))) = { \
72                 #name, __FILE__, CONNMAN_DEBUG_FLAG_ALIAS \
73         };
74
75 /**
76  * DBG:
77  * @fmt: format string
78  * @arg...: list of arguments
79  *
80  * Simple macro around connman_debug() which also include the function
81  * name it is called in.
82  */
83 #define DBG(fmt, arg...) do { \
84         static struct connman_debug_desc __connman_debug_desc \
85         __attribute__((used, section("__debug"), aligned(8))) = { \
86                 .file = __FILE__, .flags = CONNMAN_DEBUG_FLAG_DEFAULT, \
87         }; \
88         if (__connman_debug_desc.flags & CONNMAN_DEBUG_FLAG_PRINT) \
89                 connman_debug("%s:%s() " fmt, \
90                                         __FILE__, __FUNCTION__ , ## arg); \
91 } while (0)
92
93 #if defined TIZEN_EXT
94 #define simplified_log get_simple_log_option()
95 bool get_simple_log_option(void);
96 void set_simple_log_option(bool option);
97 void set_dlog_logging_option(bool option);
98 void set_file_logging_option(bool option);
99 #endif
100
101 #ifdef __cplusplus
102 }
103 #endif
104
105 #endif /* __CONNMAN_LOG_H */