aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2018-11-12 15:22:35 +0100
committerAndreas Schneider <asn@samba.org>2018-11-13 11:59:48 +0100
commitaff61a781700ce8c1e6f9d0cd74b4c484be354fa (patch)
tree9cb79477620078d8215bfba9def14d79825b010c /src
parentd26ceb542342d6eef4a8df14f79ca2f81d1e550e (diff)
downloadsocket_wrapper-aff61a781700ce8c1e6f9d0cd74b4c484be354fa.tar.gz
socket_wrapper-aff61a781700ce8c1e6f9d0cd74b4c484be354fa.tar.xz
socket_wrapper-aff61a781700ce8c1e6f9d0cd74b4c484be354fa.zip
swrap: Also log the process name
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'src')
-rw-r--r--src/socket_wrapper.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 165922b..2b77ceb 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -333,6 +333,19 @@ bool socket_wrapper_enabled(void);
void swrap_constructor(void) CONSTRUCTOR_ATTRIBUTE;
void swrap_destructor(void) DESTRUCTOR_ATTRIBUTE;
+#ifndef HAVE_GETPROGNAME
+static const char *getprogname(void)
+{
+#if defined(HAVE_PROGRAM_INVOCATION_SHORT_NAME)
+ return program_invocation_short_name;
+#elif defined(HAVE_GETEXECNAME)
+ return getexecname();
+#else
+ return NULL;
+#endif /* HAVE_PROGRAM_INVOCATION_SHORT_NAME */
+}
+#endif /* HAVE_GETPROGNAME */
+
static void swrap_log(enum swrap_dbglvl_e dbglvl, const char *func, const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
# define SWRAP_LOG(dbglvl, ...) swrap_log((dbglvl), __func__, __VA_ARGS__)
@@ -345,6 +358,7 @@ static void swrap_log(enum swrap_dbglvl_e dbglvl,
const char *d;
unsigned int lvl = 0;
const char *prefix = "SWRAP";
+ const char *progname = getprogname();
d = getenv("SOCKET_WRAPPER_DEBUGLEVEL");
if (d != NULL) {
@@ -374,9 +388,17 @@ static void swrap_log(enum swrap_dbglvl_e dbglvl,
break;
}
+ if (progname == NULL) {
+ progname = "<unknown>";
+ }
+
fprintf(stderr,
- "%s(%d) - %s: %s\n",
- prefix, (int)getpid(), func, buffer);
+ "%s[%s (%u)] - %s: %s\n",
+ prefix,
+ progname,
+ (unsigned int)getpid(),
+ func,
+ buffer);
}
/*********************************************************