network: move log_link_debug() or friends to log-link.h
This commit is contained in:
parent
8d6082e4dd
commit
e67ae9f5e6
|
@ -15,6 +15,7 @@
|
||||||
#include "sd-netlink.h"
|
#include "sd-netlink.h"
|
||||||
|
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
#include "log-link.h"
|
||||||
#include "network-util.h"
|
#include "network-util.h"
|
||||||
#include "set.h"
|
#include "set.h"
|
||||||
|
|
||||||
|
@ -179,30 +180,6 @@ uint32_t link_get_vrf_table(Link *link);
|
||||||
uint32_t link_get_dhcp_route_table(Link *link);
|
uint32_t link_get_dhcp_route_table(Link *link);
|
||||||
uint32_t link_get_ipv6_accept_ra_route_table(Link *link);
|
uint32_t link_get_ipv6_accept_ra_route_table(Link *link);
|
||||||
|
|
||||||
/* Macros which append INTERFACE= to the message */
|
|
||||||
|
|
||||||
#define log_link_full(link, level, error, ...) \
|
|
||||||
({ \
|
|
||||||
const Link *_l = (link); \
|
|
||||||
_l ? log_object_internal(level, error, __FILE__, __LINE__, __func__, "INTERFACE=", _l->ifname, NULL, NULL, ##__VA_ARGS__) : \
|
|
||||||
log_internal(level, error, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
|
|
||||||
}) \
|
|
||||||
|
|
||||||
#define log_link_debug(link, ...) log_link_full(link, LOG_DEBUG, 0, ##__VA_ARGS__)
|
|
||||||
#define log_link_info(link, ...) log_link_full(link, LOG_INFO, 0, ##__VA_ARGS__)
|
|
||||||
#define log_link_notice(link, ...) log_link_full(link, LOG_NOTICE, 0, ##__VA_ARGS__)
|
|
||||||
#define log_link_warning(link, ...) log_link_full(link, LOG_WARNING, 0, ##__VA_ARGS__)
|
|
||||||
#define log_link_error(link, ...) log_link_full(link, LOG_ERR, 0, ##__VA_ARGS__)
|
|
||||||
|
|
||||||
#define log_link_debug_errno(link, error, ...) log_link_full(link, LOG_DEBUG, error, ##__VA_ARGS__)
|
|
||||||
#define log_link_info_errno(link, error, ...) log_link_full(link, LOG_INFO, error, ##__VA_ARGS__)
|
|
||||||
#define log_link_notice_errno(link, error, ...) log_link_full(link, LOG_NOTICE, error, ##__VA_ARGS__)
|
|
||||||
#define log_link_warning_errno(link, error, ...) log_link_full(link, LOG_WARNING, error, ##__VA_ARGS__)
|
|
||||||
#define log_link_error_errno(link, error, ...) log_link_full(link, LOG_ERR, error, ##__VA_ARGS__)
|
|
||||||
|
|
||||||
#define LOG_LINK_MESSAGE(link, fmt, ...) "MESSAGE=%s: " fmt, (link)->ifname, ##__VA_ARGS__
|
|
||||||
#define LOG_LINK_INTERFACE(link) "INTERFACE=%s", (link)->ifname
|
|
||||||
|
|
||||||
#define ADDRESS_FMT_VAL(address) \
|
#define ADDRESS_FMT_VAL(address) \
|
||||||
be32toh((address).s_addr) >> 24, \
|
be32toh((address).s_addr) >> 24, \
|
||||||
(be32toh((address).s_addr) >> 16) & 0xFFu, \
|
(be32toh((address).s_addr) >> 16) & 0xFFu, \
|
||||||
|
|
37
src/shared/log-link.h
Normal file
37
src/shared/log-link.h
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following macros append INTERFACE= to the message.
|
||||||
|
* The macros require a struct named 'Link' which contains 'char *ifname':
|
||||||
|
*
|
||||||
|
* typedef struct Link {
|
||||||
|
* char *ifname;
|
||||||
|
* } Link;
|
||||||
|
*
|
||||||
|
* See, network/networkd-link.h for example.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define log_link_full(link, level, error, ...) \
|
||||||
|
({ \
|
||||||
|
const Link *_l = (link); \
|
||||||
|
(_l && _l->ifname) ? log_object_internal(level, error, __FILE__, __LINE__, __func__, "INTERFACE=", _l->ifname, NULL, NULL, ##__VA_ARGS__) : \
|
||||||
|
log_internal(level, error, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
|
||||||
|
}) \
|
||||||
|
|
||||||
|
#define log_link_debug(link, ...) log_link_full(link, LOG_DEBUG, 0, ##__VA_ARGS__)
|
||||||
|
#define log_link_info(link, ...) log_link_full(link, LOG_INFO, 0, ##__VA_ARGS__)
|
||||||
|
#define log_link_notice(link, ...) log_link_full(link, LOG_NOTICE, 0, ##__VA_ARGS__)
|
||||||
|
#define log_link_warning(link, ...) log_link_full(link, LOG_WARNING, 0, ##__VA_ARGS__)
|
||||||
|
#define log_link_error(link, ...) log_link_full(link, LOG_ERR, 0, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
#define log_link_debug_errno(link, error, ...) log_link_full(link, LOG_DEBUG, error, ##__VA_ARGS__)
|
||||||
|
#define log_link_info_errno(link, error, ...) log_link_full(link, LOG_INFO, error, ##__VA_ARGS__)
|
||||||
|
#define log_link_notice_errno(link, error, ...) log_link_full(link, LOG_NOTICE, error, ##__VA_ARGS__)
|
||||||
|
#define log_link_warning_errno(link, error, ...) log_link_full(link, LOG_WARNING, error, ##__VA_ARGS__)
|
||||||
|
#define log_link_error_errno(link, error, ...) log_link_full(link, LOG_ERR, error, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
#define LOG_LINK_MESSAGE(link, fmt, ...) "MESSAGE=%s: " fmt, (link)->ifname, ##__VA_ARGS__
|
||||||
|
#define LOG_LINK_INTERFACE(link) "INTERFACE=%s", (link)->ifname
|
|
@ -93,6 +93,7 @@ shared_sources = files('''
|
||||||
json.h
|
json.h
|
||||||
lockfile-util.c
|
lockfile-util.c
|
||||||
lockfile-util.h
|
lockfile-util.h
|
||||||
|
log-link.h
|
||||||
logs-show.c
|
logs-show.c
|
||||||
logs-show.h
|
logs-show.h
|
||||||
loop-util.c
|
loop-util.c
|
||||||
|
|
Loading…
Reference in a new issue