/// <summary> /// Configures a log to be generated based on the elapsed execution time of the code region. The log is generated at /// <see cref="LogLevel.Trace" /> level using a custom template. /// <para></para> /// The log template should contain exactly one placeholder if no custom logger arguments are provided, which the elapsed /// time will replace. If custom arguments are provided, there should be exactly one more placeholder in the log template /// than the number of custom arguments, and the placeholder for the elapsed time should appear last. /// </summary> /// <param name="setup">The <c>Setup</c> instance.</param> /// <param name="logger">The logger to log with.</param> /// <param name="template">The log template.</param> /// <param name="args">Additional logger arguments.</param> /// <returns> /// The <c>Setup</c> instance via a chainable interface. /// </returns> /// <example> /// <code> /// setup.Log(logger, "Connected to {Server} in {Elapsed}", serverUri); /// </code> /// </example> public static IChainableDisposable <Setup> Log( this Setup setup, ILogger logger, string template, params object[] args) => setup.Log(logger, LogLevel.Trace, template, args);
/// <summary> /// Configures a log to be generated based on the elapsed execution time of the code region. The log is generated at /// the specified log level using the default log template. /// </summary> /// <param name="setup">The <c>Setup</c> instance.</param> /// <param name="logger">The logger to log with.</param> /// <param name="logLevel">The level to log at.</param> /// <returns>The <c>Setup</c> instance via a chainable interface.</returns> /// <example> /// <code> /// setup.Log(logger, LogLevel.Debug); /// </code> /// </example> public static IChainableDisposable <Setup> Log(this Setup setup, ILogger logger, LogLevel logLevel) => setup.Log(logger, logLevel, DefaultLogTemplate);
/// <summary> /// Configures the elapsed execution time to be dumped to SharpPad. /// </summary> /// <param name="setup">The <c>Setup</c> instance.</param> /// <param name="title">The title to associate with the elapsed time in the SharpPad pane.</param> /// <returns>The <c>Setup</c> instance via a chainable interface.</returns> /// <remarks> /// The dump to SharpPad will be executed asynchronously. There is no guarantee that this dump will have /// completed before further configured actions on <paramref name="setup"/> begin executing. /// </remarks> /// <example> /// <code> /// setup.DumpToSharpPad("Elapsed time for algorithm"); /// </code> /// </example> public static IChainableDisposable <Setup> DumpToSharpPad(this Setup setup, string title) => setup.Do(elapsed => elapsed.Dump(title));
/// <summary> /// Configures the elapsed execution time to be dumped to SharpPad. /// </summary> /// <param name="setup">The <c>Setup</c> instance.</param> /// <param name="title">The title to associate with the elapsed time in the SharpPad pane.</param> /// <param name="port">The port the SharpPad server is running on.</param> /// <returns>The <c>Setup</c> instance via a chainable interface.</returns> /// <remarks> /// The dump to SharpPad will be executed asynchronously. There is no guarantee that this dump will have /// completed before further configured actions on <paramref name="setup"/> begin executing. /// </remarks> /// <example> /// <code> /// setup.DumpToSharpPad("Elapsed time for algorithm", 45960); /// </code> /// </example> public static IChainableDisposable <Setup> DumpToSharpPad(this Setup setup, string title, int port) => setup.Do(elapsed => elapsed.DumpOnPort(port, title));
/// <summary> /// Configures the elapsed execution time to be dumped to SharpPad. /// </summary> /// <param name="setup">The <c>Setup</c> instance.</param> /// <returns>The <c>Setup</c> instance via a chainable interface.</returns> /// <remarks> /// The dump to SharpPad will be executed asynchronously. There is no guarantee that this dump will have /// completed before further configured actions on <paramref name="setup"/> begin executing. /// </remarks> /// <example> /// <code> /// setup.DumpToSharpPad(); /// </code> /// </example> public static IChainableDisposable <Setup> DumpToSharpPad(this Setup setup) => setup.Do(elapsed => elapsed.Dump());