transport-testing-loggers2.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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-testing2.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
  32. GNUNET_TRANSPORT_TESTING_PeerContext *me,
  33. const struct GNUNET_PeerIdentity *other)
  34. {
  35. char *ps;
  36. ps = GNUNET_strdup (GNUNET_i2s (&me->id));
  37. GNUNET_log (GNUNET_ERROR_TYPE_INFO,
  38. "Peer %s connected to %u (%s)!\n",
  39. GNUNET_i2s (other),
  40. me->no,
  41. ps);
  42. GNUNET_free (ps);
  43. }
  44. /**
  45. * Log a disconnect event.
  46. *
  47. * @param cls NULL
  48. * @param me peer that had the event
  49. * @param other peer that disconnected.
  50. */
  51. void
  52. GNUNET_TRANSPORT_TESTING_log_disconnect (void *cls,
  53. struct
  54. GNUNET_TRANSPORT_TESTING_PeerContext *
  55. me,
  56. const struct
  57. GNUNET_PeerIdentity *other)
  58. {
  59. char *ps;
  60. ps = GNUNET_strdup (GNUNET_i2s (&me->id));
  61. GNUNET_log (GNUNET_ERROR_TYPE_INFO,
  62. "Peer `%s' disconnected from %u (%s)!\n",
  63. GNUNET_i2s (other),
  64. me->no,
  65. ps);
  66. GNUNET_free (ps);
  67. }
  68. /* end of transport-testing-loggers.c */