mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-24 06:56:27 +00:00
26 lines
766 B
C#
26 lines
766 B
C#
using System.Linq;
|
|
using System;
|
|
|
|
namespace SpotifyAPI.Web.Http
|
|
{
|
|
public class SimpleHTTPLogger : IHTTPLogger
|
|
{
|
|
public void OnRequest(IRequest request)
|
|
{
|
|
string parameters = null;
|
|
if (request.Parameters != null)
|
|
{
|
|
parameters = string.Join(",", request.Parameters?.Select(kv => kv.Key + "=" + kv.Value).ToArray());
|
|
}
|
|
Console.WriteLine("\n{0} {1} [{2}] {3}", request.Method, request.Endpoint, parameters, request.Body);
|
|
}
|
|
|
|
public void OnResponse(IResponse response)
|
|
{
|
|
string body = response.Body?.ToString().Replace("\n", "");
|
|
body = body?.Substring(0, Math.Min(50, body?.Length ?? 0));
|
|
Console.WriteLine("--> {0} {1} {2}\n", response.StatusCode, response.ContentType, body);
|
|
}
|
|
}
|
|
}
|