diff options
| author | Sebastien Bacher <seb128@ubuntu.com> | 2019-03-12 15:16:42 +0100 |
|---|---|---|
| committer | Sebastien Bacher <seb128@ubuntu.com> | 2019-03-12 15:16:42 +0100 |
| commit | cc4ab276f923ded9f415c1c2bf192994367ab0bb (patch) | |
| tree | ac3a7775665992b27d07eb44186d38ff961a8cd7 /src/nm-logging.h | |
| parent | bb1cf58350bb34463e9ffc5f96ac4f9b6bf46d28 (diff) | |
| parent | dd428301eb6f02542015121d7b08d9997f137e50 (diff) | |
Update upstream source from tag 'upstream/1.15.91'
Update to upstream version '1.15.91' with Debian dir 74de38245314cab529c6c94cd9d0b874ce0c2994
Diffstat (limited to 'src/nm-logging.h')
| -rw-r--r-- | src/nm-logging.h | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/src/nm-logging.h b/src/nm-logging.h index 21263c7b..a824890a 100644 --- a/src/nm-logging.h +++ b/src/nm-logging.h @@ -54,10 +54,12 @@ LOGD_IP_from_af (int addr_family) /* 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, ifname, con_uuid, ...) \ +#define _nm_log_mt(mt_require_locking, level, domain, error, ifname, con_uuid, ...) \ G_STMT_START { \ - _nm_log_impl (__FILE__, __LINE__, \ + _nm_log_impl (__FILE__, \ + __LINE__, \ _NM_LOG_FUNC, \ + (mt_require_locking), \ (level), \ (domain), \ (error), \ @@ -66,6 +68,9 @@ LOGD_IP_from_af (int addr_family) ""__VA_ARGS__); \ } G_STMT_END +#define _nm_log(level, domain, error, ifname, con_uuid, ...) \ + _nm_log_mt (!(NM_THREAD_SAFE_ON_MAIN_THREAD), level, domain, error, ifname, con_uuid, __VA_ARGS__) + /* nm_log() only evaluates its argument list after checking * whether logging for the given level/domain is enabled. */ #define nm_log(level, domain, ifname, con_uuid, ...) \ @@ -138,15 +143,35 @@ _nm_log_ptr_is_debug (NMLogLevel level) const char *nm_logging_level_to_string (void); const char *nm_logging_domains_to_string (void); +/*****************************************************************************/ + extern NMLogDomain _nm_logging_enabled_state[_LOGL_N_REAL]; + static inline gboolean -nm_logging_enabled (NMLogLevel level, NMLogDomain domain) +_nm_logging_enabled_lockfree (NMLogLevel level, NMLogDomain domain) { nm_assert (((guint) level) < G_N_ELEMENTS (_nm_logging_enabled_state)); return (((guint) level) < G_N_ELEMENTS (_nm_logging_enabled_state)) && !!(_nm_logging_enabled_state[level] & domain); } +gboolean _nm_logging_enabled_locking (NMLogLevel level, NMLogDomain domain); + +static inline gboolean +nm_logging_enabled_mt (gboolean mt_require_locking, NMLogLevel level, NMLogDomain domain) +{ + if (mt_require_locking) + return _nm_logging_enabled_locking (level, domain); + + NM_ASSERT_ON_MAIN_THREAD (); + return _nm_logging_enabled_lockfree (level, domain); +} + +#define nm_logging_enabled(level, domain) \ + nm_logging_enabled_mt (!(NM_THREAD_SAFE_ON_MAIN_THREAD), level, domain) + +/*****************************************************************************/ + NMLogLevel nm_logging_get_level (NMLogDomain domain); const char *nm_logging_all_levels_to_string (void); @@ -157,10 +182,11 @@ gboolean nm_logging_setup (const char *level, char **bad_domains, GError **error); -void nm_logging_set_syslog_identifier (const char *domain); -void nm_logging_set_prefix (const char *format, ...) _nm_printf (1, 2); +void nm_logging_init_pre (const char *syslog_identifier, + char *prefix_take); + +void nm_logging_init (const char *logging_backend, gboolean debug); -void nm_logging_syslog_openlog (const char *logging_backend, gboolean debug); gboolean nm_logging_syslog_enabled (void); /*****************************************************************************/ @@ -271,8 +297,6 @@ gboolean nm_logging_syslog_enabled (void); #define _LOG3t_err(errsv, ...) G_STMT_START { if (FALSE) { _NMLOG3_err (errsv, LOGL_TRACE, __VA_ARGS__); } } G_STMT_END #endif -extern void (*_nm_logging_clear_platform_logging_cache) (void); - /*****************************************************************************/ #define __NMLOG_DEFAULT(level, domain, prefix, ...) \ @@ -292,4 +316,8 @@ extern void (*_nm_logging_clear_platform_logging_cache) (void); _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ } G_STMT_END +/*****************************************************************************/ + +extern void _nm_logging_clear_platform_logging_cache (void); + #endif /* __NETWORKMANAGER_LOGGING_H__ */ |