-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Logging: All-up logging improvements:
- New DbContextOption "LogSqlParameterValues()" replacing use of Debug log level to control sensitive data logging. - Introduced ISensitiveDataLogger to be used when logging sensitive data. - More consistentizing of logging usage, DI etc. - Better structured logging of DbCommands. - Use assembly scoped enums for event ids. - Use event ids everywhere. Fix #1374, #2490
- Loading branch information
Showing
69 changed files
with
569 additions
and
373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/EntityFramework.Core/Extensions/Internal/CoreLoggerExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using Microsoft.Data.Entity.Infrastructure; | ||
using Microsoft.Framework.Logging; | ||
|
||
namespace Microsoft.Data.Entity.Extensions.Internal | ||
{ | ||
internal static class CoreLoggerExtensions | ||
{ | ||
public static void LogError<TState>( | ||
this ILogger logger, CoreLoggingEventId eventId, Func<TState> state, Exception exception, Func<Exception, string> formatter) | ||
{ | ||
if (logger.IsEnabled(LogLevel.Error)) | ||
{ | ||
logger.Log(LogLevel.Error, (int)eventId, state(), exception, (_, e) => formatter(e)); | ||
} | ||
} | ||
|
||
public static void LogVerbose(this ILogger logger, CoreLoggingEventId eventId, Func<string> formatter) | ||
{ | ||
if (logger.IsEnabled(LogLevel.Verbose)) | ||
{ | ||
logger.Log(LogLevel.Verbose, (int)eventId, null, null, (_, __) => formatter()); | ||
} | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/EntityFramework.Core/Infrastructure/CoreLoggingEventId.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
namespace Microsoft.Data.Entity.Infrastructure | ||
{ | ||
public enum CoreLoggingEventId | ||
{ | ||
DatabaseError = 1, | ||
CompilingQueryModel, | ||
OptimizedQueryModel, | ||
IncludingNavigation, | ||
TrackingQuerySources, | ||
QueryPlan | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/EntityFramework.InMemory/Extensions/Internal/InMemoryLoggerExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using Microsoft.Data.Entity.Infrastructure; | ||
using Microsoft.Framework.Logging; | ||
|
||
namespace Microsoft.Data.Entity.Extensions.Internal | ||
{ | ||
internal static class CoreLoggerExtensions | ||
{ | ||
public static void LogInformation<TState>( | ||
this ILogger logger, InMemoryLoggingEventId eventId, TState state, Func<TState, string> formatter) | ||
{ | ||
if (logger.IsEnabled(LogLevel.Information)) | ||
{ | ||
logger.Log(LogLevel.Information, (int)eventId, state, null, (s, _) => formatter((TState)s)); | ||
} | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/EntityFramework.InMemory/Infrastructure/InMemoryLoggingEventId.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
namespace Microsoft.Data.Entity.Infrastructure | ||
{ | ||
public enum InMemoryLoggingEventId | ||
{ | ||
SavedChanges = 1 | ||
} | ||
} |
Oops, something went wrong.