From 8583791eb38729a8d5c6cbffd9fa30d401ef441e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 5 Jul 2016 18:43:49 +0200 Subject: [PATCH] logging: don't log the function name The function name is no longer visible in the default logging output. It is anyway only used together with journal logging to set "CODE_FUNC". Drop it. It allows to remove the strings from the binary, which decreases the object size of a default build of NetworkManager from 2437400 to 2412824 bytes (-24k, -1%). --- src/nm-logging.c | 3 ++- src/nm-logging.h | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/nm-logging.c b/src/nm-logging.c index 15e1492876..d3b4715b2b 100644 --- a/src/nm-logging.c +++ b/src/nm-logging.c @@ -664,7 +664,8 @@ _nm_log_impl (const char *file, _iovec_set_format (iov, iov_free, i_field++, "NM_LOG_DOMAINS=%s", s_domain_1); } _iovec_set_format (iov, iov_free, i_field++, "NM_LOG_LEVEL=%s", global.level_desc[level].name); - _iovec_set_format (iov, iov_free, i_field++, "CODE_FUNC=%s", func ?: ""); + if (func) + _iovec_set_format (iov, iov_free, i_field++, "CODE_FUNC=%s", func); _iovec_set_format (iov, iov_free, i_field++, "CODE_FILE=%s", file ?: ""); _iovec_set_format (iov, iov_free, i_field++, "CODE_LINE=%u", line); _iovec_set_format (iov, iov_free, i_field++, "TIMESTAMP_MONOTONIC=%lld.%06lld", (long long) (now / NM_UTILS_NS_PER_SECOND), (long long) ((now % NM_UTILS_NS_PER_SECOND) / 1000)); diff --git a/src/nm-logging.h b/src/nm-logging.h index 655f675465..9e2b0108ef 100644 --- a/src/nm-logging.h +++ b/src/nm-logging.h @@ -103,12 +103,20 @@ typedef enum { /*< skip >*/ #define nm_log_dbg(domain, ...) nm_log (LOGL_DEBUG, (domain), __VA_ARGS__) #define nm_log_trace(domain, ...) nm_log (LOGL_TRACE, (domain), __VA_ARGS__) +//#define _NM_LOG_FUNC G_STRFUNC +#define _NM_LOG_FUNC NULL + /* 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__); \ + _nm_log_impl (__FILE__, __LINE__, \ + _NM_LOG_FUNC, \ + (level), \ + (domain), \ + (error), \ + ""__VA_ARGS__); \ } G_STMT_END /* nm_log() only evaluates it's argument list after checking