Skip to content

Commit

Permalink
Updates logging from plugins. Closes #887 (#890)
Browse files Browse the repository at this point in the history
  • Loading branch information
waldekmastykarz authored Oct 3, 2024
1 parent 198d66c commit b9e7765
Show file tree
Hide file tree
Showing 43 changed files with 7,977 additions and 7,778 deletions.
46 changes: 23 additions & 23 deletions dev-proxy-abstractions/ILoggerExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
using System.Text.Json;
using Microsoft.DevProxy.Abstractions;

#pragma warning disable IDE0130
namespace Microsoft.Extensions.Logging;
#pragma warning restore IDE0130

public static class ILoggerExtensions
{
public static void LogRequest(this ILogger logger, string[] message, MessageType messageType, LoggingContext? context = null)
{
logger.Log(new RequestLog(message, messageType, context));
}

public static void LogRequest(this ILogger logger, string[] message, MessageType messageType, string method, string url)
{
logger.Log(new RequestLog(message, messageType, method, url));
}

public static void Log(this ILogger logger, RequestLog message)
{
logger.Log(LogLevel.Information, 0, message, exception: null, (m, _) => JsonSerializer.Serialize(m));
}
using System.Text.Json;
using Microsoft.DevProxy.Abstractions;

#pragma warning disable IDE0130
namespace Microsoft.Extensions.Logging;
#pragma warning restore IDE0130

public static class ILoggerExtensions
{
public static void LogRequest(this ILogger logger, string message, MessageType messageType, LoggingContext? context = null)
{
logger.Log(new RequestLog(message, messageType, context));
}

public static void LogRequest(this ILogger logger, string message, MessageType messageType, string method, string url)
{
logger.Log(new RequestLog(message, messageType, method, url));
}

public static void Log(this ILogger logger, RequestLog message)
{
logger.Log(LogLevel.Information, 0, message, exception: null, (m, _) => JsonSerializer.Serialize(m));
}
}
56 changes: 25 additions & 31 deletions dev-proxy-abstractions/IProxyLogger.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using Titanium.Web.Proxy.EventArguments;
using Microsoft.Extensions.Logging;

namespace Microsoft.DevProxy.Abstractions;

public enum MessageType
{
Normal,
InterceptedRequest,
PassedThrough,
Warning,
Tip,
Failed,
Chaos,
Mocked,
InterceptedResponse,
FinishedProcessingRequest
}

public class LoggingContext(SessionEventArgs session)
{
public SessionEventArgs Session { get; } = session;
}

public interface IProxyLogger : ICloneable, ILogger
{
public LogLevel LogLevel { get; set; }
public void LogRequest(string[] message, MessageType messageType, LoggingContext? context = null);
public void LogRequest(string[] message, MessageType messageType, string method, string url);
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Titanium.Web.Proxy.EventArguments;

namespace Microsoft.DevProxy.Abstractions;

public enum MessageType
{
Normal,
InterceptedRequest,
PassedThrough,
Warning,
Tip,
Failed,
Chaos,
Mocked,
InterceptedResponse,
FinishedProcessingRequest,
Skipped
}

public class LoggingContext(SessionEventArgs session)
{
public SessionEventArgs Session { get; } = session;
}
Loading

0 comments on commit b9e7765

Please sign in to comment.