Logging API changes
This commit is contained in:
parent
e9fb79a4fb
commit
ddd369f7d9
|
|
@ -31,7 +31,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public SendFileMiddleware([NotNull] RequestDelegate next, [NotNull] ILoggerFactory loggerFactory)
|
||||
{
|
||||
_next = next;
|
||||
_logger = loggerFactory.Create<SendFileMiddleware>();
|
||||
_logger = loggerFactory.CreateLogger<SendFileMiddleware>();
|
||||
}
|
||||
|
||||
public Task Invoke(HttpContext context)
|
||||
|
|
@ -94,7 +94,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
fileStream.Seek(offset, SeekOrigin.Begin);
|
||||
if (_logger.IsEnabled(LogLevel.Verbose))
|
||||
{
|
||||
_logger.WriteVerbose(string.Format("Copying bytes {0}-{1} of file {2} to response body", offset, length != null ? (offset + length).ToString() : "*", fileName));
|
||||
_logger.LogVerbose(string.Format("Copying bytes {0}-{1} of file {2} to response body", offset, length != null ? (offset + length).ToString() : "*", fileName));
|
||||
}
|
||||
await StreamCopyOperation.CopyToAsync(fileStream, _output, length, cancel);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
// The spec allows for multiple ranges but we choose not to support them because the client may request
|
||||
// very strange ranges (e.g. each byte separately, overlapping ranges, etc.) that could negatively
|
||||
// impact the server. Ignore the header and serve the response normally.
|
||||
_logger.WriteWarning("Multiple ranges are not allowed: '{0}'", rangeHeader.ToString());
|
||||
_logger.LogWarning("Multiple ranges are not allowed: '{0}'", rangeHeader.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -314,7 +314,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
|
||||
if (_logger.IsEnabled(LogLevel.Verbose))
|
||||
{
|
||||
_logger.WriteVerbose(string.Format("Handled. Status code: {0} File: {1}", statusCode, SubPath));
|
||||
_logger.LogVerbose(string.Format("Handled. Status code: {0} File: {1}", statusCode, SubPath));
|
||||
}
|
||||
return Constants.CompletedTask;
|
||||
}
|
||||
|
|
@ -358,7 +358,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
// the current length of the selected resource. e.g. */length
|
||||
_responseHeaders.ContentRange = new ContentRangeHeaderValue(_length);
|
||||
ApplyResponseHeaders(Constants.Status416RangeNotSatisfiable);
|
||||
_logger.WriteWarning("Range not satisfiable for {0}", SubPath);
|
||||
_logger.LogWarning("Range not satisfiable for {0}", SubPath);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -376,7 +376,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
{
|
||||
if (_logger.IsEnabled(LogLevel.Verbose))
|
||||
{
|
||||
_logger.WriteVerbose(string.Format("Sending {0} of file {1}", _response.Headers[HeaderNames.ContentRange], physicalPath));
|
||||
_logger.LogVerbose(string.Format("Sending {0} of file {1}", _response.Headers[HeaderNames.ContentRange], physicalPath));
|
||||
}
|
||||
await sendFile.SendFileAsync(physicalPath, start, length, _context.RequestAborted);
|
||||
return;
|
||||
|
|
@ -388,7 +388,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
readStream.Seek(start, SeekOrigin.Begin); // TODO: What if !CanSeek?
|
||||
if (_logger.IsEnabled(LogLevel.Verbose))
|
||||
{
|
||||
_logger.WriteVerbose(string.Format("Copying {0} of file {1} to the response body", _response.Headers[HeaderNames.ContentRange], SubPath));
|
||||
_logger.LogVerbose(string.Format("Copying {0} of file {1} to the response body", _response.Headers[HeaderNames.ContentRange], SubPath));
|
||||
}
|
||||
await StreamCopyOperation.CopyToAsync(readStream, _response.Body, length, _context.RequestAborted);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
_next = next;
|
||||
_options = options;
|
||||
_matchUrl = options.RequestPath;
|
||||
_logger = loggerFactory.Create<StaticFileMiddleware>();
|
||||
_logger = loggerFactory.CreateLogger<StaticFileMiddleware>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -70,14 +70,14 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
}
|
||||
if (_logger.IsEnabled(LogLevel.Verbose))
|
||||
{
|
||||
_logger.WriteVerbose(string.Format("Copying file {0} to the response body", fileContext.SubPath));
|
||||
_logger.LogVerbose(string.Format("Copying file {0} to the response body", fileContext.SubPath));
|
||||
}
|
||||
return fileContext.SendAsync();
|
||||
|
||||
case StaticFileContext.PreconditionState.NotModified:
|
||||
if (_logger.IsEnabled(LogLevel.Verbose))
|
||||
{
|
||||
_logger.WriteVerbose(string.Format("{0} not modified", fileContext.SubPath));
|
||||
_logger.LogVerbose(string.Format("{0} not modified", fileContext.SubPath));
|
||||
}
|
||||
return fileContext.SendStatusAsync(Constants.Status304NotModified);
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
|
||||
default:
|
||||
var exception = new NotImplementedException(fileContext.GetPreconditionState().ToString());
|
||||
_logger.WriteError("No precondition state specified", exception);
|
||||
_logger.LogError("No precondition state specified", exception);
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue