X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Flogging.c;h=26f8ddddc9cbbd638176f70f81d66766a4ab94a9;hb=b0a676988a8da3120e64ef0e1a4ea4c28b1511e1;hp=ed595779a2438509c9c723e25a1397d4d26b40d8;hpb=8822481d7b11db72d5400717d6b491b5f36bcb1f;p=meshlink diff --git a/src/logging.c b/src/logging.c index ed595779..26f8dddd 100644 --- a/src/logging.c +++ b/src/logging.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: logging.c,v 1.2 2002/04/13 10:28:56 zarq Exp $ + $Id: logging.c,v 1.5 2002/04/13 18:01:58 zarq Exp $ */ #include "config.h" @@ -74,13 +74,33 @@ void log_del_hook(log_function_t *fn) void log_default(int level, int priority, char *fmt, va_list ap) { if(debug_lvl >= level) - vfprintf(stderr, fmt, ap); + { + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + } } void log_syslog(int level, int priority, char *fmt, va_list ap) { - int priorities[] = { LOG_DEBUG, LOG_INFO, LOG_NOTICE, LOG_ERR, LOG_CRIT }; + const int priorities[] = { LOG_DEBUG, LOG_INFO, LOG_NOTICE, LOG_ERR, LOG_CRIT }; if(debug_lvl >= level) vsyslog(priorities[priority], fmt, ap); } + +void tinc_syslog(int priority, char *fmt, ...) +{ + /* Mapping syslog prio -> tinc prio */ + const int priorities[] = { TLOG_CRITICAL, TLOG_CRITICAL, TLOG_CRITICAL, TLOG_ERROR, + TLOG_NOTICE, TLOG_NOTICE, TLOG_INFO, TLOG_DEBUG }; + avl_node_t *avlnode; + va_list args; + + va_start(args, fmt); + for(avlnode = log_hooks_tree->head; avlnode; avlnode = avlnode->next) + { + assert(avlnode->data); + ((log_function_t*)(avlnode->data))(0, priorities[priority], fmt, args); + } + va_end(args); +}