-
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.
Add EventId, LogLevel, and message generation for event payloads
Issue #7939 Also adds nominal types for all events other than those in the relational design assemblies. (Since these assemblies are currently being refactored.) Each event payload now contains all the information needed to create and log the message for the event, including overridden ToString that creates the message.
- Loading branch information
1 parent
15dbcb8
commit 2782a55
Showing
66 changed files
with
2,009 additions
and
337 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// 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 System.Diagnostics; | ||
using JetBrains.Annotations; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Diagnostics | ||
{ | ||
/// <summary> | ||
/// A <see cref="DiagnosticSource" /> event payload class for events that have | ||
/// an associated <see cref="Migrations.Migration" />. | ||
/// </summary> | ||
public class MigrationDesignEventData : EventDataBase | ||
{ | ||
/// <summary> | ||
/// Constructs the event payload. | ||
/// </summary> | ||
/// <param name="eventDefinition"> The event definition. </param> | ||
/// <param name="messageGenerator"> A delegate that generates a log message for this event. </param> | ||
/// <param name="migration"> The <see cref="Migration" />. </param> | ||
public MigrationDesignEventData( | ||
[NotNull] EventDefinitionBase eventDefinition, | ||
[NotNull] Func<EventDefinitionBase, EventDataBase, string> messageGenerator, | ||
[NotNull] Migration migration) | ||
: base(eventDefinition, messageGenerator) | ||
{ | ||
Migration = migration; | ||
} | ||
|
||
/// <summary> | ||
/// The <see cref="Migration" />. | ||
/// </summary> | ||
public virtual Migration Migration { get; } | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/EFCore.Design/Diagnostics/MigrationFileNameEventData.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,45 @@ | ||
// 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 System.Diagnostics; | ||
using JetBrains.Annotations; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Diagnostics | ||
{ | ||
/// <summary> | ||
/// A <see cref="DiagnosticSource" /> event payload class for events that have | ||
/// an associated <see cref="Migrations.Migration" /> and file name. | ||
/// </summary> | ||
public class MigrationFileNameEventData : EventDataBase | ||
{ | ||
/// <summary> | ||
/// Constructs the event payload. | ||
/// </summary> | ||
/// <param name="eventDefinition"> The event definition. </param> | ||
/// <param name="messageGenerator"> A delegate that generates a log message for this event. </param> | ||
/// <param name="migration"> The <see cref="Migration" />. </param> | ||
/// <param name="fileName"> The file name. </param> | ||
public MigrationFileNameEventData( | ||
[NotNull] EventDefinitionBase eventDefinition, | ||
[NotNull] Func<EventDefinitionBase, EventDataBase, string> messageGenerator, | ||
[NotNull] Migration migration, | ||
[NotNull] string fileName) | ||
: base(eventDefinition, messageGenerator) | ||
{ | ||
Migration = migration; | ||
FileName = fileName; | ||
} | ||
|
||
/// <summary> | ||
/// The <see cref="Migration" />. | ||
/// </summary> | ||
public virtual Migration Migration { get; } | ||
|
||
/// <summary> | ||
/// The file name. | ||
/// </summary> | ||
public virtual string FileName { get; } | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/EFCore.Design/Diagnostics/MigrationOperationsEventData.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,38 @@ | ||
// 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 System.Collections.Generic; | ||
using System.Diagnostics; | ||
using JetBrains.Annotations; | ||
using Microsoft.EntityFrameworkCore.Migrations.Operations; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Diagnostics | ||
{ | ||
/// <summary> | ||
/// A <see cref="DiagnosticSource" /> event payload class for events that have | ||
/// associated <see cref="MigrationOperation" />s. | ||
/// </summary> | ||
public class MigrationOperationsEventData : EventDataBase | ||
{ | ||
/// <summary> | ||
/// Constructs the event payload. | ||
/// </summary> | ||
/// <param name="eventDefinition"> The event definition. </param> | ||
/// <param name="messageGenerator"> A delegate that generates a log message for this event. </param> | ||
/// <param name="operations"> The operations. </param> | ||
public MigrationOperationsEventData( | ||
[NotNull] EventDefinitionBase eventDefinition, | ||
[NotNull] Func<EventDefinitionBase, EventDataBase, string> messageGenerator, | ||
[NotNull] IEnumerable<MigrationOperation> operations) | ||
: base(eventDefinition, messageGenerator) | ||
{ | ||
Operations = operations; | ||
} | ||
|
||
/// <summary> | ||
/// The operations. | ||
/// </summary> | ||
public virtual IEnumerable<MigrationOperation> Operations { get; } | ||
} | ||
} |
Oops, something went wrong.