From: Guus Sliepen Date: Tue, 19 May 2015 19:23:35 +0000 (+0200) Subject: Add source of SPTPS errors to log messages. X-Git-Tag: release-1.1pre12~144 X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=a7522118018928e17fc53840b420df570cf1bec5;p=tinc Add source of SPTPS errors to log messages. --- diff --git a/src/logger.c b/src/logger.c index 2b4c7e38..2defb239 100644 --- a/src/logger.c +++ b/src/logger.c @@ -1,6 +1,6 @@ /* logger.c -- logging code - Copyright (C) 2004-2013 Guus Sliepen + Copyright (C) 2004-2015 Guus Sliepen 2004-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -114,9 +114,17 @@ void logger(int level, int priority, const char *format, ...) { static void sptps_logger(sptps_t *s, int s_errno, const char *format, va_list ap) { char message[1024] = ""; - int len = vsnprintf(message, sizeof message, format, ap); - if(len > 0 && len < sizeof message && message[len - 1] == '\n') - message[len - 1] = 0; + size_t msglen = sizeof message; + + int len = vsnprintf(message, msglen, format, ap); + if(len > 0 && len < sizeof message) { + if(message[len - 1] == '\n') + message[--len] = 0; + + connection_t *c = s->handle; + if(c) + snprintf(message + len, sizeof message - len, " from %s (%s)", c->name, c->hostname); + } real_logger(DEBUG_ALWAYS, LOG_ERR, message); }