Remove logger dependencies.
This commit is contained in:
parent
9de989fd54
commit
0ad0fc6a9f
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Globalization;
|
|
||||||
using Microsoft.Framework.Logging;
|
using Microsoft.Framework.Logging;
|
||||||
|
|
||||||
namespace Microsoft.Net.Http.Server
|
namespace Microsoft.Net.Http.Server
|
||||||
|
|
@ -34,7 +33,7 @@ namespace Microsoft.Net.Http.Server
|
||||||
{
|
{
|
||||||
if (factory == null)
|
if (factory == null)
|
||||||
{
|
{
|
||||||
factory = new LoggerFactory();
|
return new NullLogger();
|
||||||
}
|
}
|
||||||
|
|
||||||
return factory.CreateLogger(type.FullName);
|
return factory.CreateLogger(type.FullName);
|
||||||
|
|
@ -87,5 +86,29 @@ namespace Microsoft.Net.Http.Server
|
||||||
logger.LogError(location + "; " + message);
|
logger.LogError(location + "; " + message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class NullLogger : ILogger
|
||||||
|
{
|
||||||
|
public IDisposable BeginScopeImpl(object state)
|
||||||
|
{
|
||||||
|
return new NullDispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsEnabled(LogLevel logLevel)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Log(LogLevel logLevel, int eventId, object state, Exception exception, Func<object, Exception, string> formatter)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private class NullDispose : IDisposable
|
||||||
|
{
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -514,7 +514,7 @@ namespace Microsoft.Net.Http.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ReceiveRequestLogContext : ReflectionBasedLogValues
|
private class ReceiveRequestLogContext : ILogValues
|
||||||
{
|
{
|
||||||
private readonly Request _request;
|
private readonly Request _request;
|
||||||
|
|
||||||
|
|
@ -530,6 +530,19 @@ namespace Microsoft.Net.Http.Server
|
||||||
public string Protocol { get { return "HTTP/" + _request.ProtocolVersion.ToString(2); } }
|
public string Protocol { get { return "HTTP/" + _request.ProtocolVersion.ToString(2); } }
|
||||||
public IEnumerable Headers { get { return new HeadersLogStructure(_request.Headers); } }
|
public IEnumerable Headers { get { return new HeadersLogStructure(_request.Headers); } }
|
||||||
|
|
||||||
|
public IEnumerable<KeyValuePair<string, object>> GetValues()
|
||||||
|
{
|
||||||
|
return new[]
|
||||||
|
{
|
||||||
|
new KeyValuePair<string, object>("Method", Method),
|
||||||
|
new KeyValuePair<string, object>("PathBase", PathBase),
|
||||||
|
new KeyValuePair<string, object>("Path", Path),
|
||||||
|
new KeyValuePair<string, object>("Query", Query),
|
||||||
|
new KeyValuePair<string, object>("Protocol", Protocol),
|
||||||
|
new KeyValuePair<string, object>("Headers", Headers),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
var requestBuilder = new StringBuilder("Received request: ");
|
var requestBuilder = new StringBuilder("Received request: ");
|
||||||
|
|
|
||||||
|
|
@ -883,7 +883,7 @@ namespace Microsoft.Net.Http.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SendResponseLogContext : ReflectionBasedLogValues
|
private class SendResponseLogContext : ILogValues
|
||||||
{
|
{
|
||||||
private readonly Response _response;
|
private readonly Response _response;
|
||||||
|
|
||||||
|
|
@ -897,6 +897,17 @@ namespace Microsoft.Net.Http.Server
|
||||||
public string ReasonPhrase { get { return _response.ReasonPhrase ?? _response.GetReasonPhrase(_response.StatusCode); } }
|
public string ReasonPhrase { get { return _response.ReasonPhrase ?? _response.GetReasonPhrase(_response.StatusCode); } }
|
||||||
public IEnumerable Headers { get { return new HeadersLogStructure(_response.Headers); } }
|
public IEnumerable Headers { get { return new HeadersLogStructure(_response.Headers); } }
|
||||||
|
|
||||||
|
public IEnumerable<KeyValuePair<string, object>> GetValues()
|
||||||
|
{
|
||||||
|
return new[]
|
||||||
|
{
|
||||||
|
new KeyValuePair<string, object>("Protocol", Protocol),
|
||||||
|
new KeyValuePair<string, object>("StatusCode", StatusCode),
|
||||||
|
new KeyValuePair<string, object>("ReasonPhrase", ReasonPhrase),
|
||||||
|
new KeyValuePair<string, object>("Headers", Headers),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
// HTTP/1.1 200 OK
|
// HTTP/1.1 200 OK
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ namespace Microsoft.Net.Http.Server
|
||||||
private long? _requestQueueLength;
|
private long? _requestQueueLength;
|
||||||
|
|
||||||
public WebListener()
|
public WebListener()
|
||||||
: this(new LoggerFactory())
|
: this(null)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue