transport-testing-loggers.c 2.2 KB

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