< Summary

Information
Class: Renci.SshNet.Abstractions.DiagnosticAbstraction
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Abstractions\DiagnosticAbstraction.cs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 69
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.cctor()100%1100%
Log(...)100%1100%

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\Abstractions\DiagnosticAbstraction.cs

#LineLine coverage
 1using System.ComponentModel;
 2using System.Diagnostics;
 3
 4namespace Renci.SshNet.Abstractions
 5{
 6    /// <summary>
 7    /// Provides access to the <see cref="System.Diagnostics"/> internals of SSH.NET.
 8    /// </summary>
 9    [EditorBrowsable(EditorBrowsableState.Never)]
 10    public static class DiagnosticAbstraction
 11    {
 12        /// <summary>
 13        /// The <see cref="TraceSource"/> instance used by SSH.NET.
 14        /// </summary>
 15        /// <remarks>
 16        /// <para>
 17        /// Currently, the library only traces events when compiled in Debug mode.
 18        /// </para>
 19        /// <para>
 20        /// Configuration on .NET Core must be done programmatically, e.g.
 21        /// <code>
 22        /// DiagnosticAbstraction.Source.Switch = new SourceSwitch("sourceSwitch", "Verbose");
 23        /// DiagnosticAbstraction.Source.Listeners.Remove("Default");
 24        /// DiagnosticAbstraction.Source.Listeners.Add(new ConsoleTraceListener());
 25        /// DiagnosticAbstraction.Source.Listeners.Add(new TextWriterTraceListener("trace.log"));
 26        /// </code>
 27        /// </para>
 28        /// <para>
 29        /// On .NET Framework, it is possible to configure via App.config, e.g.
 30        /// <code>
 31        /// <![CDATA[
 32        /// <configuration>
 33        ///     <system.diagnostics>
 34        ///         <trace autoflush="true"/>
 35        ///         <sources>
 36        ///             <source name="SshNet.Logging" switchValue="Verbose">
 37        ///                 <listeners>
 38        ///                     <remove name="Default" />
 39        ///                     <add name="console"
 40        ///                          type="System.Diagnostics.ConsoleTraceListener" />
 41        ///                     <add name="logFile"
 42        ///                          type="System.Diagnostics.TextWriterTraceListener"
 43        ///                          initializeData="SshNetTrace.log" />
 44        ///                 </listeners>
 45        ///             </source>
 46        ///         </sources>
 47        ///     </system.diagnostics>
 48        /// </configuration>
 49        /// ]]>
 50        /// </code>
 51        /// </para>
 52        /// </remarks>
 453        public static readonly TraceSource Source = new TraceSource("SshNet.Logging");
 54
 55        /// <summary>
 56        /// Logs a message to <see cref="Source"/> at the <see cref="TraceEventType.Verbose"/>
 57        /// level.
 58        /// </summary>
 59        /// <param name="text">The message to log.</param>
 60        /// <param name="type">The trace event type.</param>
 61        [Conditional("DEBUG")]
 62        public static void Log(string text, TraceEventType type = TraceEventType.Verbose)
 13695263        {
 13695264            Source.TraceEvent(type,
 13695265                              System.Environment.CurrentManagedThreadId,
 13695266                              text);
 13695267        }
 68    }
 69}