/
dev-npgsql
/
npgsql
Обзор
Документация
Войти
/
dev-npgsql
/
npgsql
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
v4.1.15
src/Npgsql/NpgsqlSqlEventSource.cs
31 строка
1 KB
Shay Rojansky
Move Command start/stop out of NpgsqlEventSource (#3023)
16 июн 2020, 15:24
16 июн 2020, 15:24
1d33f68
Код
Авторство
О чём код?
using System.Diagnostics.Tracing; using System.Runtime.CompilerServices; namespace Npgsql { sealed class NpgsqlSqlEventSource : EventSource { static readonly NpgsqlSqlEventSource Log = new NpgsqlSqlEventSource(); const string EventSourceName = "Npgsql.Sql"; const int CommandStartId = 3; const int CommandStopId = 4; internal NpgsqlSqlEventSource() : base(EventSourceName) {} // NOTE // - The 'Start' and 'Stop' suffixes on the following event names have special meaning in EventSource. They // enable creating 'activities'. // For more information, take a look at the following blog post: // https://blogs.msdn.microsoft.com/vancem/2015/09/14/exploring-eventsource-activity-correlation-and-causation-features/ // - A stop event's event id must be next one after its start event. [Event(CommandStartId, Level = EventLevel.Informational)] public static void CommandStart(string sql) => Log.WriteEvent(CommandStartId, sql); [MethodImpl(MethodImplOptions.NoInlining)] [Event(CommandStopId, Level = EventLevel.Informational)] public static void CommandStop() => Log.WriteEvent(CommandStopId); } }