2008-11-03 04:13:42 +00:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
2006-02-27 04:31:52 +00:00
|
|
|
/* NetworkManager -- Network link manager
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
2008-06-26 18:31:52 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2006-02-27 04:31:52 +00:00
|
|
|
*
|
2012-10-31 17:19:38 +01:00
|
|
|
* Copyright (C) 2006 - 2012 Red Hat, Inc.
|
2008-11-03 04:13:42 +00:00
|
|
|
* Copyright (C) 2006 - 2008 Novell, Inc.
|
2006-02-27 04:31:52 +00:00
|
|
|
*/
|
|
|
|
|
|
all: fix up multiple-include-guard defines
Previously, src/nm-ip4-config.h, libnm/nm-ip4-config.h, and
libnm-glib/nm-ip4-config.h all used "NM_IP4_CONFIG_H" as an include
guard, which meant that nm-test-utils.h could not tell which of them
was being included (and so, eg, if you tried to include
nm-ip4-config.h in a libnm test, it would fail to compile because
nm-test-utils.h was referring to symbols in src/nm-ip4-config.h).
Fix this by changing the include guards in the non-API-stable parts of
the tree:
- libnm-glib/nm-ip4-config.h remains NM_IP4_CONFIG_H
- libnm/nm-ip4-config.h now uses __NM_IP4_CONFIG_H__
- src/nm-ip4-config.h now uses __NETWORKMANAGER_IP4_CONFIG_H__
And likewise for all other headers.
The two non-"nm"-prefixed headers, libnm/NetworkManager.h and
src/NetworkManagerUtils.h are now __NETWORKMANAGER_H__ and
__NETWORKMANAGER_UTILS_H__ respectively, which, while not entirely
consistent with the general scheme, do still mostly make sense in
isolation.
2014-08-13 14:10:11 -04:00
|
|
|
#ifndef __NETWORKMANAGER_LOGGING_H__
|
|
|
|
|
#define __NETWORKMANAGER_LOGGING_H__
|
2006-02-27 04:31:52 +00:00
|
|
|
|
2014-04-14 12:03:05 +02:00
|
|
|
#ifdef __NM_TEST_UTILS_H__
|
|
|
|
|
#error nm-test-utils.h must be included as last header
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-07-17 14:38:54 +02:00
|
|
|
#include "nm-logging.h"
|
2006-02-27 04:31:52 +00:00
|
|
|
|
2015-07-17 14:38:54 +02:00
|
|
|
#include "nm-default.h"
|
2015-06-01 13:42:08 +02:00
|
|
|
#include "nm-macros-internal.h"
|
2014-02-12 21:54:26 +01:00
|
|
|
|
2010-04-06 15:23:08 -07:00
|
|
|
/* Log domains */
|
2014-10-30 12:44:36 +01:00
|
|
|
typedef enum { /*< skip >*/
|
2013-08-16 12:25:21 -04:00
|
|
|
LOGD_NONE = 0LL,
|
2014-10-30 12:41:17 +01:00
|
|
|
LOGD_PLATFORM = (1LL << 0), /* Platform services */
|
|
|
|
|
LOGD_RFKILL = (1LL << 1),
|
|
|
|
|
LOGD_ETHER = (1LL << 2),
|
|
|
|
|
LOGD_WIFI = (1LL << 3),
|
|
|
|
|
LOGD_BT = (1LL << 4),
|
|
|
|
|
LOGD_MB = (1LL << 5), /* mobile broadband */
|
|
|
|
|
LOGD_DHCP4 = (1LL << 6),
|
|
|
|
|
LOGD_DHCP6 = (1LL << 7),
|
|
|
|
|
LOGD_PPP = (1LL << 8),
|
|
|
|
|
LOGD_WIFI_SCAN = (1LL << 9),
|
|
|
|
|
LOGD_IP4 = (1LL << 10),
|
|
|
|
|
LOGD_IP6 = (1LL << 11),
|
|
|
|
|
LOGD_AUTOIP4 = (1LL << 12),
|
|
|
|
|
LOGD_DNS = (1LL << 13),
|
|
|
|
|
LOGD_VPN = (1LL << 14),
|
|
|
|
|
LOGD_SHARING = (1LL << 15), /* Connection sharing/dnsmasq */
|
|
|
|
|
LOGD_SUPPLICANT = (1LL << 16), /* WiFi and 802.1x */
|
|
|
|
|
LOGD_AGENTS = (1LL << 17), /* Secret agents */
|
|
|
|
|
LOGD_SETTINGS = (1LL << 18), /* Settings */
|
|
|
|
|
LOGD_SUSPEND = (1LL << 19), /* Suspend/Resume */
|
|
|
|
|
LOGD_CORE = (1LL << 20), /* Core daemon and policy stuff */
|
|
|
|
|
LOGD_DEVICE = (1LL << 21), /* Device state and activation */
|
|
|
|
|
LOGD_OLPC = (1LL << 22),
|
wimax: drop WiMAX support (bgo #747846)
Even Fedora is no longer shipping the WiMAX SDK, so it's likely we'll
eventually accidentally break some of the code in src/devices/wimax/
(if we haven't already). Discussion on the list showed a consensus for
dropping support for WiMAX.
So, remove the SDK checks from configure.ac, remove the WiMAX device
plugin and associated manager support, and deprecate all the APIs.
For compatibility reasons, it is still possible to create and save
WiMAX connections, to toggle the software WiMAX rfkill state, and to
change the "WIMAX" log level, although none of these have any effect,
since no NMDeviceWimax will ever be created.
nmcli was only compiling in support for most WiMAX operations when NM
as a whole was built with WiMAX support, so that code has been removed
now as well. (It is still possible to use nmcli to create and edit
WiMAX connections, but those connections will never be activatable.)
2015-04-13 17:07:00 -04:00
|
|
|
LOGD_INFINIBAND = (1LL << 23),
|
|
|
|
|
LOGD_FIREWALL = (1LL << 24),
|
|
|
|
|
LOGD_ADSL = (1LL << 25),
|
|
|
|
|
LOGD_BOND = (1LL << 26),
|
|
|
|
|
LOGD_VLAN = (1LL << 27),
|
|
|
|
|
LOGD_BRIDGE = (1LL << 28),
|
|
|
|
|
LOGD_DBUS_PROPS = (1LL << 29),
|
|
|
|
|
LOGD_TEAM = (1LL << 30),
|
|
|
|
|
LOGD_CONCHECK = (1LL << 31),
|
|
|
|
|
LOGD_DCB = (1LL << 32), /* Data Center Bridging */
|
|
|
|
|
LOGD_DISPATCH = (1LL << 33),
|
2015-07-13 10:19:33 +02:00
|
|
|
LOGD_AUDIT = (1LL << 34),
|
2010-04-06 15:23:08 -07:00
|
|
|
|
2014-10-30 12:44:36 +01:00
|
|
|
__LOGD_MAX,
|
|
|
|
|
LOGD_ALL = ((__LOGD_MAX - 1LL) << 1) - 1LL,
|
|
|
|
|
LOGD_DEFAULT = LOGD_ALL & ~(
|
|
|
|
|
LOGD_DBUS_PROPS |
|
|
|
|
|
LOGD_WIFI_SCAN |
|
|
|
|
|
0),
|
|
|
|
|
|
|
|
|
|
/* aliases: */
|
|
|
|
|
LOGD_DHCP = LOGD_DHCP4 | LOGD_DHCP6,
|
|
|
|
|
LOGD_IP = LOGD_IP4 | LOGD_IP6,
|
|
|
|
|
LOGD_HW = LOGD_PLATFORM,
|
|
|
|
|
} NMLogDomain;
|
2010-04-06 18:06:36 -07:00
|
|
|
|
2010-04-06 15:23:08 -07:00
|
|
|
/* Log levels */
|
2014-10-30 12:44:36 +01:00
|
|
|
typedef enum { /*< skip >*/
|
2014-04-14 14:26:13 +02:00
|
|
|
LOGL_TRACE,
|
2013-10-01 11:40:22 -04:00
|
|
|
LOGL_DEBUG,
|
|
|
|
|
LOGL_INFO,
|
|
|
|
|
LOGL_WARN,
|
|
|
|
|
LOGL_ERR,
|
|
|
|
|
|
2015-08-01 14:12:34 +02:00
|
|
|
_LOGL_N_REAL, /* the number of actual logging levels */
|
|
|
|
|
|
|
|
|
|
_LOGL_OFF = _LOGL_N_REAL, /* special logging level that is always disabled. */
|
|
|
|
|
|
|
|
|
|
_LOGL_N, /* the number of logging levels including "OFF" */
|
2014-10-30 12:44:36 +01:00
|
|
|
} NMLogLevel;
|
2010-04-06 15:23:08 -07:00
|
|
|
|
2014-07-22 22:15:00 +02:00
|
|
|
#define nm_log_err(domain, ...) nm_log (LOGL_ERR, (domain), __VA_ARGS__)
|
|
|
|
|
#define nm_log_warn(domain, ...) nm_log (LOGL_WARN, (domain), __VA_ARGS__)
|
|
|
|
|
#define nm_log_info(domain, ...) nm_log (LOGL_INFO, (domain), __VA_ARGS__)
|
|
|
|
|
#define nm_log_dbg(domain, ...) nm_log (LOGL_DEBUG, (domain), __VA_ARGS__)
|
2014-04-14 14:26:13 +02:00
|
|
|
#define nm_log_trace(domain, ...) nm_log (LOGL_TRACE, (domain), __VA_ARGS__)
|
2010-04-06 15:46:03 -07:00
|
|
|
|
2015-04-22 11:11:44 +02:00
|
|
|
/* A wrapper for the _nm_log_impl() function that adds call site information.
|
|
|
|
|
* Contrary to nm_log(), it unconditionally calls the function without
|
|
|
|
|
* checking whether logging for the given level and domain is enabled. */
|
|
|
|
|
#define _nm_log(level, domain, error, ...) \
|
|
|
|
|
G_STMT_START { \
|
|
|
|
|
_nm_log_impl (__FILE__, __LINE__, G_STRFUNC, (level), (domain), (error), ""__VA_ARGS__); \
|
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
2014-02-12 11:44:12 +01:00
|
|
|
/* nm_log() only evaluates it's argument list after checking
|
|
|
|
|
* whether logging for the given level/domain is enabled. */
|
2014-07-22 22:15:00 +02:00
|
|
|
#define nm_log(level, domain, ...) \
|
2014-02-12 11:44:12 +01:00
|
|
|
G_STMT_START { \
|
|
|
|
|
if (nm_logging_enabled ((level), (domain))) { \
|
2015-04-22 11:11:44 +02:00
|
|
|
_nm_log (level, domain, 0, __VA_ARGS__); \
|
2014-02-12 11:44:12 +01:00
|
|
|
} \
|
|
|
|
|
} G_STMT_END
|
2010-04-06 15:23:08 -07:00
|
|
|
|
2014-02-12 21:54:26 +01:00
|
|
|
|
|
|
|
|
#define _nm_log_ptr(level, domain, self, ...) \
|
|
|
|
|
nm_log ((level), (domain), "[%p] " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), self _NM_UTILS_MACRO_REST(__VA_ARGS__))
|
|
|
|
|
|
|
|
|
|
/* log a message for an object (with providing a generic @self pointer) */
|
|
|
|
|
#define nm_log_ptr(level, domain, self, ...) \
|
|
|
|
|
G_STMT_START { \
|
2015-03-18 18:09:08 +01:00
|
|
|
NM_PRAGMA_WARNING_DISABLE("-Wtautological-compare") \
|
2014-02-12 21:54:26 +01:00
|
|
|
if ((level) <= LOGL_DEBUG) { \
|
|
|
|
|
_nm_log_ptr ((level), (domain), (self), __VA_ARGS__); \
|
|
|
|
|
} else { \
|
|
|
|
|
nm_log ((level), (domain), __VA_ARGS__); \
|
|
|
|
|
} \
|
2015-03-18 18:09:08 +01:00
|
|
|
NM_PRAGMA_WARNING_REENABLE \
|
2014-02-12 21:54:26 +01:00
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define _nm_log_obj(level, domain, self, ...) \
|
|
|
|
|
_nm_log_ptr ((level), (domain), (self), __VA_ARGS__)
|
|
|
|
|
|
|
|
|
|
/* log a message for an object (with providing a @self pointer to a GObject).
|
|
|
|
|
* Contrary to nm_log_ptr(), @self must be a GObject type (or %NULL).
|
|
|
|
|
* As of now, nm_log_obj() is identical to nm_log_ptr(), but we might change that */
|
|
|
|
|
#define nm_log_obj(level, domain, self, ...) \
|
|
|
|
|
nm_log_ptr ((level), (domain), (self), __VA_ARGS__)
|
|
|
|
|
|
|
|
|
|
|
2015-04-22 11:06:49 +02:00
|
|
|
void _nm_log_impl (const char *file,
|
|
|
|
|
guint line,
|
|
|
|
|
const char *func,
|
|
|
|
|
NMLogLevel level,
|
|
|
|
|
NMLogDomain domain,
|
|
|
|
|
int error,
|
|
|
|
|
const char *fmt,
|
|
|
|
|
...) __attribute__((__format__ (__printf__, 7, 8)));
|
2010-04-06 15:23:08 -07:00
|
|
|
|
2014-02-12 11:17:26 +01:00
|
|
|
const char *nm_logging_level_to_string (void);
|
2014-02-12 11:30:29 +01:00
|
|
|
const char *nm_logging_domains_to_string (void);
|
2014-10-30 12:44:36 +01:00
|
|
|
gboolean nm_logging_enabled (NMLogLevel level, NMLogDomain domain);
|
2010-05-04 12:06:00 -07:00
|
|
|
|
2013-03-11 12:23:57 -04:00
|
|
|
const char *nm_logging_all_levels_to_string (void);
|
|
|
|
|
const char *nm_logging_all_domains_to_string (void);
|
|
|
|
|
|
2013-11-26 11:33:42 -05:00
|
|
|
gboolean nm_logging_setup (const char *level,
|
|
|
|
|
const char *domains,
|
|
|
|
|
char **bad_domains,
|
|
|
|
|
GError **error);
|
2015-07-08 19:34:34 +02:00
|
|
|
void nm_logging_syslog_openlog (const char *logging_backend);
|
2006-02-27 04:31:52 +00:00
|
|
|
|
all: fix up multiple-include-guard defines
Previously, src/nm-ip4-config.h, libnm/nm-ip4-config.h, and
libnm-glib/nm-ip4-config.h all used "NM_IP4_CONFIG_H" as an include
guard, which meant that nm-test-utils.h could not tell which of them
was being included (and so, eg, if you tried to include
nm-ip4-config.h in a libnm test, it would fail to compile because
nm-test-utils.h was referring to symbols in src/nm-ip4-config.h).
Fix this by changing the include guards in the non-API-stable parts of
the tree:
- libnm-glib/nm-ip4-config.h remains NM_IP4_CONFIG_H
- libnm/nm-ip4-config.h now uses __NM_IP4_CONFIG_H__
- src/nm-ip4-config.h now uses __NETWORKMANAGER_IP4_CONFIG_H__
And likewise for all other headers.
The two non-"nm"-prefixed headers, libnm/NetworkManager.h and
src/NetworkManagerUtils.h are now __NETWORKMANAGER_H__ and
__NETWORKMANAGER_UTILS_H__ respectively, which, while not entirely
consistent with the general scheme, do still mostly make sense in
isolation.
2014-08-13 14:10:11 -04:00
|
|
|
#endif /* __NETWORKMANAGER_LOGGING_H__ */
|