1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-03 09:02:48 -05:00

Add logging to tokenables (#2298)

* Add logging to token usages

* Add settings manipulation of log levels

* Maintain no logging for dev

* Log exception causing Token failure in TryUnprotect

* dotnet format 🤖

* Added deconstruction operator on new debug logs.

* Split off log level settings into separate files

* Improve log messages

* dotnet format 🤖

* Fix token serialization

* Final review notes

Co-authored-by: Todd Martin <>
This commit is contained in:
Matt Gibson
2022-09-26 15:22:02 -04:00
committed by GitHub
parent 02bea3c48d
commit c8c9b32904
29 changed files with 255 additions and 57 deletions

View File

@ -31,13 +31,16 @@ public static class LoggerFactoryExtensions
public static ILoggingBuilder AddSerilog(
this ILoggingBuilder builder,
WebHostBuilderContext context,
Func<LogEvent, bool> filter = null)
Func<LogEvent, IGlobalSettings, bool> filter = null)
{
if (context.HostingEnvironment.IsDevelopment())
{
return builder;
}
var globalSettings = new GlobalSettings();
ConfigurationBinder.Bind(context.Configuration.GetSection("GlobalSettings"), globalSettings);
bool inclusionPredicate(LogEvent e)
{
if (filter == null)
@ -49,12 +52,9 @@ public static class LoggerFactoryExtensions
{
return true;
}
return filter(e);
return filter(e, globalSettings);
}
var globalSettings = new GlobalSettings();
ConfigurationBinder.Bind(context.Configuration.GetSection("GlobalSettings"), globalSettings);
var config = new LoggerConfiguration()
.Enrich.FromLogContext()
.Filter.ByIncludingOnly(inclusionPredicate);