| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="PerformanceLoggerMessages.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System; |
| | | 8 | | using Microsoft.Extensions.Logging; |
| | | 9 | | |
| | | 10 | | namespace MyNet.Utilities.Logging; |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// Defines strongly-typed logging messages for performance logging. These messages are used by the <see cref="Performan |
| | | 14 | | /// </summary> |
| | | 15 | | internal static partial class PerformanceLoggerMessages |
| | | 16 | | { |
| | 3 | 17 | | private static readonly Func<ILogger, string, IDisposable?> Scope = LoggerMessage.DefineScope<string>("{PerformanceS |
| | | 18 | | |
| | | 19 | | [LoggerMessage(EventId = 1000, Level = LogLevel.Trace, Message = "START - {Title}")] |
| | | 20 | | public static partial void LogStart(this ILogger logger, string title); |
| | | 21 | | |
| | | 22 | | [LoggerMessage(EventId = 1001, Level = LogLevel.Trace, Message = "END - {Title} : {Elapsed}")] |
| | | 23 | | public static partial void LogEnd(this ILogger logger, string title, string elapsed); |
| | | 24 | | |
| | | 25 | | [LoggerMessage(EventId = 1002, Level = LogLevel.Information, Message = "{Title} completed in {Elapsed}")] |
| | | 26 | | public static partial void LogCompleted(this ILogger logger, string title, string elapsed); |
| | | 27 | | |
| | | 28 | | [LoggerMessage(EventId = 1003, Level = LogLevel.Information, Message = "{Separator} {Title} {Separator}")] |
| | | 29 | | public static partial void LogHeader(this ILogger logger, string separator, string title); |
| | | 30 | | |
| | | 31 | | [LoggerMessage(EventId = 1004, Level = LogLevel.Information, Message = "{Key} - {Elapsed}")] |
| | | 32 | | public static partial void LogEntry(this ILogger logger, string key, string elapsed); |
| | | 33 | | |
| | | 34 | | [LoggerMessage(EventId = 1005, Level = LogLevel.Information, Message = "Total Time : {Elapsed}")] |
| | | 35 | | public static partial void LogTotal(this ILogger logger, string elapsed); |
| | | 36 | | |
| | 0 | 37 | | public static IDisposable? BeginScope(this ILogger logger, string message) => Scope(logger, message); |
| | | 38 | | } |
| | | 39 | | |