Instead of each middleware having to log that it has started and ended,
the DianosticListner package allows for capturing of these events in a
lightwieght manner.
This commit implements this and removes unncessary logging from most
middleware.
OcelotLogger now has a property called "Name" intended to store the name
of the type for which the logger has been built for. This is intended to
keep the code a little bit cleaner and also allows for a few extention
methods for common logging scenarios
Modifications are as follows
var applicableReRoutes = configuration.Data.ReRoutes.Where(r => string.Equals(r.UpstreamHttpMethod.Method.ToLower(), upstreamHttpMethod.ToLower(), StringComparison.CurrentCultureIgnoreCase));
As part #35 logging is being checked. This commit changes the first four
middlewares within the pipeline to be more standardised.
Also added an extension method to easily print out the errors from a list
of errors.
Added LogError(string) to interface as sometimes there isn't an exception
to be logged. Additionally, split Logger and LoggerFactory implementations
into seperate files just for tidiness.
Additonally added some very basic unit tests to the HttpDataRepository as
a bit of regression safety and to prove that Get never returns a null.
Slightly refactored the logic within AspDotNetLogger under
GetMessageWithOcelotRequestId so that the if statement is a little easier
to read. Attempted to remove the requestId == null, however this broke
numerous tests as the mocks don't set the behviour for dataReposioty
getting the requestId
Previously only LogDebug and LogError were implemented, however this
could/will lead to very noisy logging. Implementing trace should allow a
better seperation when debugging.
Following TomPallister suggestion, it makes sense to call GetType only
once and in the constructor (middlewares are only instantiated once). I
have also taken the oppturniuty to add it as a property on the base
middleware allowing any other middleware to utlise it as well.
As part of #66 we realised that the implementation of
IErrorToHttpStatusCodeMapper would always return a wrapped StatusCode
within an OK response, in turn meaning that ResponderMiddleware would
never fall into the else branch for returning a 500.
This commit removes the wrapping of the status code and removes the unused
logic for generating the 500 status code, giving the mapper full
responsbility for generating the correct status code.
As part of #35 we are we are standardising on using IOcelotLoggerFactory
over the default ILogger for DI purposes. Following a sln search, the use
of ILogger was only found in one place (FileOcelotConfigurationCreator)
and it's corresponding tests.
This commit changes them and ensures the unit tests still pass.