-Merge branch 'master' of ssh://gnunet.org/gnunet into gsoc2018/rest_api
[oweals/gnunet.git] / src / transport / transport-testing-loggers.c
1
2 /*
3      This file is part of GNUnet.
4      Copyright (C) 2016 GNUnet e.V.
5
6      GNUnet is free software: you can redistribute it and/or modify it
7      under the terms of the GNU Affero General Public License as published
8      by the Free Software Foundation, either version 3 of the License,
9      or (at your option) any later version.
10
11      GNUnet is distributed in the hope that it will be useful, but
12      WITHOUT ANY WARRANTY; without even the implied warranty of
13      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14      Affero General Public License for more details.
15     
16      You should have received a copy of the GNU Affero General Public License
17      along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 /**
20  * @file transport-testing-loggers.c
21  * @brief convenience functions for logging common events in tests
22  * @author Christian Grothoff
23  */
24 #include "transport-testing.h"
25
26
27 /**
28  * Log a connect event.
29  *
30  * @param cls NULL
31  * @param me peer that had the event
32  * @param other peer that connected.
33  */
34 void
35 GNUNET_TRANSPORT_TESTING_log_connect (void *cls,
36                                       struct GNUNET_TRANSPORT_TESTING_PeerContext *me,
37                                       const struct GNUNET_PeerIdentity *other)
38 {
39   char *ps;
40
41   ps = GNUNET_strdup (GNUNET_i2s (&me->id));
42   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
43               "Peer %s connected to %u (%s)!\n",
44               GNUNET_i2s (other),
45               me->no,
46               ps);
47   GNUNET_free (ps);
48 }
49
50
51
52 /**
53  * Log a disconnect event.
54  *
55  * @param cls NULL
56  * @param me peer that had the event
57  * @param other peer that disconnected.
58  */
59 void
60 GNUNET_TRANSPORT_TESTING_log_disconnect (void *cls,
61                                          struct GNUNET_TRANSPORT_TESTING_PeerContext *me,
62                                          const struct GNUNET_PeerIdentity *other)
63 {
64   char *ps;
65
66   ps = GNUNET_strdup (GNUNET_i2s (&me->id));
67   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
68               "Peer `%s' disconnected from %u (%s)!\n",
69               GNUNET_i2s (other),
70               me->no,
71               ps);
72   GNUNET_free (ps);
73 }
74
75 /* end of transport-testing-loggers.c */