Blame src/goabackend/goasouplogger.c

Packit 79f644
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
Packit 79f644
/*
Packit 79f644
 * Copyright © 2017 Red Hat, Inc.
Packit 79f644
 *
Packit 79f644
 * This library is free software; you can redistribute it and/or
Packit 79f644
 * modify it under the terms of the GNU Lesser General Public
Packit 79f644
 * License as published by the Free Software Foundation; either
Packit 79f644
 * version 2 of the License, or (at your option) any later version.
Packit 79f644
 *
Packit 79f644
 * This library is distributed in the hope that it will be useful,
Packit 79f644
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 79f644
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 79f644
 * Lesser General Public License for more details.
Packit 79f644
 *
Packit 79f644
 * You should have received a copy of the GNU Lesser General
Packit 79f644
 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
Packit 79f644
 */
Packit 79f644
Packit 79f644
#include "config.h"
Packit 79f644
Packit 79f644
#include <glib.h>
Packit 79f644
Packit 79f644
#include "goasouplogger.h"
Packit 79f644
Packit 79f644
struct _GoaSoupLogger
Packit 79f644
{
Packit 79f644
  SoupLogger parent_instance;
Packit 79f644
};
Packit 79f644
Packit 79f644
G_DEFINE_TYPE (GoaSoupLogger, goa_soup_logger, SOUP_TYPE_LOGGER);
Packit 79f644
Packit 79f644
/* ---------------------------------------------------------------------------------------------------- */
Packit 79f644
Packit 79f644
static void
Packit 79f644
goa_soup_logger_printer (SoupLogger         *logger,
Packit 79f644
                         SoupLoggerLogLevel  level,
Packit 79f644
                         gchar               direction,
Packit 79f644
                         const gchar        *data,
Packit 79f644
                         gpointer            user_data)
Packit 79f644
{
Packit 79f644
  gchar *message;
Packit 79f644
Packit 79f644
  message = g_strdup_printf ("%c %s", direction, data);
Packit 79f644
  g_log_default_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, message, NULL);
Packit 79f644
  g_free (message);
Packit 79f644
}
Packit 79f644
Packit 79f644
/* ---------------------------------------------------------------------------------------------------- */
Packit 79f644
Packit 79f644
static void
Packit 79f644
goa_soup_logger_init (GoaSoupLogger *self)
Packit 79f644
{
Packit 79f644
  soup_logger_set_printer (SOUP_LOGGER (self), goa_soup_logger_printer, NULL, NULL);
Packit 79f644
}
Packit 79f644
Packit 79f644
static void
Packit 79f644
goa_soup_logger_class_init (GoaSoupLoggerClass *klass)
Packit 79f644
{
Packit 79f644
}
Packit 79f644
Packit 79f644
/* ---------------------------------------------------------------------------------------------------- */
Packit 79f644
Packit 79f644
SoupLogger *
Packit 79f644
goa_soup_logger_new (SoupLoggerLogLevel   level,
Packit 79f644
                     gint                 max_body_size)
Packit 79f644
{
Packit 79f644
  return g_object_new (GOA_TYPE_SOUP_LOGGER, "level", level, "max-body-size", max_body_size, NULL);
Packit 79f644
}