3 * Copyright (C) 2014 Samsung Electronics. All rights reserved.
4 * @Author: Reynaldo H. Verdejo Pinochet <r.verdejo@sisa.samsung.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more
20 #include <libsoup/soup.h>
21 #include "gstsouputils.h"
27 GST_DEBUG_CATEGORY_EXTERN (soup_utils_debug);
28 #define GST_CAT_DEFAULT soup_utils_debug
31 gst_soup_util_log_make_level_tag (SoupLoggerLogLevel level)
35 if (G_UNLIKELY ((gint) level > 9))
39 case SOUP_LOGGER_LOG_MINIMAL:
42 case SOUP_LOGGER_LOG_HEADERS:
45 case SOUP_LOGGER_LOG_BODY:
49 /* Unknown level. If this is hit libsoup likely added a new
50 * log level to SoupLoggerLogLevel and it should be added
59 gst_soup_util_log_printer_cb (SoupLogger G_GNUC_UNUSED * logger,
60 SoupLoggerLogLevel level, char direction, const char *data,
64 c = gst_soup_util_log_make_level_tag (level);
65 GST_TRACE_OBJECT (GST_ELEMENT (user_data), "HTTP_SESSION(%c): %c %s", c,
70 gst_soup_util_log_setup (SoupSession * session, SoupLoggerLogLevel level,
76 GST_INFO_OBJECT (element, "Not attaching a logger with level 0");
80 g_assert (session && element);
82 if (gst_debug_category_get_threshold (GST_CAT_DEFAULT)
84 GST_INFO_OBJECT (element, "Not setting up HTTP session logger. "
85 "Need at least GST_LEVEL_TRACE");
89 /* Create a new logger and set body_size_limit to -1 (no limit) */
90 logger = soup_logger_new (level, -1);
91 soup_logger_set_printer (logger, gst_soup_util_log_printer_cb,
92 gst_object_ref (element), (GDestroyNotify) gst_object_unref);
94 /* Attach logger to session */
95 soup_session_add_feature (session, SOUP_SESSION_FEATURE (logger));
96 g_object_unref (logger);