| Public | A secure communication stack for .NET using JSON-RPC over SSL.
Other
12
stars
44
forks
source link
Adds support for sending logs to multiple destinations e.g. to both a in memory log as well as to something else which can be selective about what it logs. #485
Makes it possible to add a customer ILogFactory which logs specific events or records metrics while also still logging to the in memory logger.
Here is a very spelled out example of how to use the new classes:
// A thing that creates a new `InMemoryConnectionLog` on each call.
// Create a single one for performance to cache the LogProvider.GetLogger("Halibut")
ICreateNewILog singleInMemoryConntionLogCreator = new InMemoryConnectionLogCreator();
// These log writers only record and can never return logs.
ILogWriter logConnectionErrors = new LogConnectionErrors();
ILogWriter logSecurityEvents = new LogSecurityEvents();
Func<string, ILogWriter[]> logWriterCreator = prefix => new[] {logConnectionErrors, logSecurityEvents};
// Aggregate the logWriters and the in memory connection log creator
ICreateNewILog aggregateLoggerCreator = new AggregateLogWriterLogCreator(singleInMemoryConntionLogCreator, logWriterCreator);
// Now we need it to be a log factory, and for the ILogs to be cached.
ILogFactory logFactory = aggregateLoggerCreator.ToCachingLogFactory();
Changes:
Adds a new ICreateNewILog which makes new ILogs.
Adds a InMemoryConnectionLogCreator which just creates new InMemoryConnectionLog
Adds a ILogWriter which is just like a ILog except that it is write only, you can't read back logs.
Adds a CachingLogFactory which copies the caching logic from LogFactory. Doing so means it is easy to add new ways of logging since they don't need to concern themselves with caching.
Removes TestContextLogFactory.cs and replaces it with TestContextLogCreator which is much simpler thanks to splitting out the caching.
Removes the AggregateILog from tests since we now have this capability from Halibut.
Adds a AggregateLogWriterLog which sends logs to both a ILog as well as a set of ILogWriter.
How to review this PR
Quality :heavy_check_mark:
Pre-requisites
[ ] I have read How we use GitHub Issues for help deciding when and where it's appropriate to make an issue.
[ ] I have considered informing or consulting the right people, according to the ownership map.
[ ] I have considered appropriate testing for my change.
Background
[SC-55402]
Makes it possible to add a customer
ILogFactory
which logs specific events or records metrics while also still logging to the in memory logger.Here is a very spelled out example of how to use the new classes:
Changes:
ICreateNewILog
which makes newILog
s.InMemoryConnectionLogCreator
which just creates newInMemoryConnectionLog
ILogWriter
which is just like aILog
except that it is write only, you can't read back logs.CachingLogFactory
which copies the caching logic fromLogFactory
. Doing so means it is easy to add new ways of logging since they don't need to concern themselves with caching.TestContextLogFactory.cs
and replaces it withTestContextLogCreator
which is much simpler thanks to splitting out the caching.AggregateILog
from tests since we now have this capability from Halibut.AggregateLogWriterLog
which sends logs to both aILog
as well as a set ofILogWriter
.How to review this PR
Quality :heavy_check_mark:
Pre-requisites