summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2017-07-31 18:25:42 +0200
committerAndreas Schneider <asn@samba.org>2017-09-07 07:57:10 +0200
commitb5a67f495620a38371cec166e05fa7010df8298a (patch)
tree4f46a23e50b555bafdccfc2873b3de09af56feaf /src
parent49d7a4efd7a7de5a0962b358eb6e8c560a3f4711 (diff)
downloadsocket_wrapper-b5a67f495620a38371cec166e05fa7010df8298a.tar.gz
socket_wrapper-b5a67f495620a38371cec166e05fa7010df8298a.tar.xz
socket_wrapper-b5a67f495620a38371cec166e05fa7010df8298a.zip
swrap: Simplify printing different log prefixes
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'src')
-rw-r--r--src/socket_wrapper.c41
1 files changed, 18 insertions, 23 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 5a9d212..11d708a 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -361,6 +361,7 @@ static void swrap_log(enum swrap_dbglvl_e dbglvl,
va_list va;
const char *d;
unsigned int lvl = 0;
+ const char *prefix = "SWRAP";
d = getenv("SOCKET_WRAPPER_DEBUGLEVEL");
if (d != NULL) {
@@ -375,30 +376,24 @@ static void swrap_log(enum swrap_dbglvl_e dbglvl,
vsnprintf(buffer, sizeof(buffer), format, va);
va_end(va);
- if (lvl >= dbglvl) {
- switch (dbglvl) {
- case SWRAP_LOG_ERROR:
- fprintf(stderr,
- "SWRAP_ERROR(%d) - %s: %s\n",
- (int)getpid(), func, buffer);
- break;
- case SWRAP_LOG_WARN:
- fprintf(stderr,
- "SWRAP_WARN(%d) - %s: %s\n",
- (int)getpid(), func, buffer);
- break;
- case SWRAP_LOG_DEBUG:
- fprintf(stderr,
- "SWRAP_DEBUG(%d) - %s: %s\n",
- (int)getpid(), func, buffer);
- break;
- case SWRAP_LOG_TRACE:
- fprintf(stderr,
- "SWRAP_TRACE(%d) - %s: %s\n",
- (int)getpid(), func, buffer);
- break;
- }
+ switch (dbglvl) {
+ case SWRAP_LOG_ERROR:
+ prefix = "SWRAP_ERROR";
+ break;
+ case SWRAP_LOG_WARN:
+ prefix = "SWRAP_WARN";
+ break;
+ case SWRAP_LOG_DEBUG:
+ prefix = "SWRAP_DEBUG";
+ break;
+ case SWRAP_LOG_TRACE:
+ prefix = "SWRAP_TRACE";
+ break;
}
+
+ fprintf(stderr,
+ "%s(%d) - %s: %s\n",
+ prefix, (int)getpid(), func, buffer);
}
/*********************************************************