This repository has been archived by the owner on Oct 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also made the package automatically initialize its own manager to the SystemDiagnostics one so that TraceSources can be configured from any consuming libraryo
- Loading branch information
Showing
15 changed files
with
1,364 additions
and
4 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
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,64 @@ | ||
#region BSD License | ||
/* | ||
Copyright (c) 2011, Clarius Consulting | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, this list | ||
of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, this | ||
list of conditions and the following disclaimer in the documentation and/or other | ||
materials provided with the distribution. | ||
* Neither the name of Clarius Consulting nor the names of its contributors may be | ||
used to endorse or promote products derived from this software without specific | ||
prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY | ||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT | ||
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED | ||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | ||
DAMAGE. | ||
*/ | ||
#endregion | ||
|
||
namespace ReactiveSockets.Diagnostics | ||
{ | ||
using System; | ||
using System.Diagnostics; | ||
|
||
/// <summary> | ||
/// Interface used by the application components to log messages. | ||
/// </summary> | ||
/// <nuget id="Tracer.Interfaces" /> | ||
partial interface ITracer | ||
{ | ||
/// <summary> | ||
/// Traces the specified message with the given <see cref="TraceEventType"/>. | ||
/// </summary> | ||
void Trace(TraceEventType type, object message); | ||
|
||
/// <summary> | ||
/// Traces the specified formatted message with the given <see cref="TraceEventType"/>. | ||
/// </summary> | ||
void Trace(TraceEventType type, string format, params object[] args); | ||
|
||
/// <summary> | ||
/// Traces an exception with the specified message and <see cref="TraceEventType"/>. | ||
/// </summary> | ||
void Trace(TraceEventType type, Exception exception, object message); | ||
|
||
/// <summary> | ||
/// Traces an exception with the specified formatted message and <see cref="TraceEventType"/>. | ||
/// </summary> | ||
void Trace(TraceEventType type, Exception exception, string format, params object[] args); | ||
} | ||
} |
224 changes: 224 additions & 0 deletions
224
ReactiveSockets/External/Diagnostics/Tracer/ITracerExtensions.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,224 @@ | ||
#region BSD License | ||
/* | ||
Copyright (c) 2011, Clarius Consulting | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, this list | ||
of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, this | ||
list of conditions and the following disclaimer in the documentation and/or other | ||
materials provided with the distribution. | ||
* Neither the name of Clarius Consulting nor the names of its contributors may be | ||
used to endorse or promote products derived from this software without specific | ||
prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY | ||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT | ||
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED | ||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | ||
DAMAGE. | ||
*/ | ||
#endregion | ||
|
||
namespace ReactiveSockets.Diagnostics | ||
{ | ||
using System; | ||
using System.Diagnostics; | ||
|
||
/// <summary> | ||
/// Provides usability overloads for tracing to a <see cref="ITracer"/>. | ||
/// </summary> | ||
/// <nuget id="Tracer.Interfaces" /> | ||
static partial class ITracerExtensions | ||
{ | ||
#region Critical overloads | ||
|
||
/// <summary> | ||
/// Traces an event of type <see cref="TraceEventType.Critical"/> with the given message; | ||
/// </summary> | ||
public static void Critical(this ITracer tracer, object message) | ||
{ | ||
tracer.Trace(TraceEventType.Critical, message); | ||
} | ||
|
||
/// <summary> | ||
/// Traces an event of type <see cref="TraceEventType.Critical"/> with the given format string and arguments. | ||
/// </summary> | ||
public static void Critical(this ITracer tracer, string format, params object[] args) | ||
{ | ||
tracer.Trace(TraceEventType.Critical, format, args); | ||
} | ||
|
||
/// <summary> | ||
/// Traces an event of type <see cref="TraceEventType.Critical"/> with the given exception and message. | ||
/// </summary> | ||
public static void Critical(this ITracer tracer, Exception exception, object message) | ||
{ | ||
tracer.Trace(TraceEventType.Critical, exception, message); | ||
} | ||
|
||
/// <summary> | ||
/// Traces an event of type <see cref="TraceEventType.Critical"/> with the given exception, format string and arguments. | ||
/// </summary> | ||
public static void Critical(this ITracer tracer, Exception exception, string format, params object[] args) | ||
{ | ||
tracer.Trace(TraceEventType.Critical, exception, format, args); | ||
} | ||
|
||
#endregion | ||
|
||
#region Error overloads | ||
|
||
/// <summary> | ||
/// Traces an event of type <see cref="TraceEventType.Error"/> with the given message; | ||
/// </summary> | ||
public static void Error(this ITracer tracer, object message) | ||
{ | ||
tracer.Trace(TraceEventType.Error, message); | ||
} | ||
|
||
/// <summary> | ||
/// Traces an event of type <see cref="TraceEventType.Error"/> with the given format string and arguments. | ||
/// </summary> | ||
public static void Error(this ITracer tracer, string format, params object[] args) | ||
{ | ||
tracer.Trace(TraceEventType.Error, format, args); | ||
} | ||
|
||
/// <summary> | ||
/// Traces an event of type <see cref="TraceEventType.Error"/> with the given exception and message. | ||
/// </summary> | ||
public static void Error(this ITracer tracer, Exception exception, object message) | ||
{ | ||
tracer.Trace(TraceEventType.Error, exception, message); | ||
} | ||
|
||
/// <summary> | ||
/// Traces an event of type <see cref="TraceEventType.Error"/> with the given exception, format string and arguments. | ||
/// </summary> | ||
public static void Error(this ITracer tracer, Exception exception, string format, params object[] args) | ||
{ | ||
tracer.Trace(TraceEventType.Error, exception, format, args); | ||
} | ||
|
||
#endregion | ||
|
||
#region Warn overloads | ||
|
||
/// <summary> | ||
/// Traces an event of type <see cref="TraceEventType.Warning"/> with the given message; | ||
/// </summary> | ||
public static void Warn(this ITracer tracer, object message) | ||
{ | ||
tracer.Trace(TraceEventType.Warning, message); | ||
} | ||
|
||
/// <summary> | ||
/// Traces an event of type <see cref="TraceEventType.Warning"/> with the given format string and arguments. | ||
/// </summary> | ||
public static void Warn(this ITracer tracer, string format, params object[] args) | ||
{ | ||
tracer.Trace(TraceEventType.Warning, format, args); | ||
} | ||
|
||
/// <summary> | ||
/// Traces an event of type <see cref="TraceEventType.Warning"/> with the given exception and message. | ||
/// </summary> | ||
public static void Warn(this ITracer tracer, Exception exception, object message) | ||
{ | ||
tracer.Trace(TraceEventType.Warning, exception, message); | ||
} | ||
|
||
/// <summary> | ||
/// Traces an event of type <see cref="TraceEventType.Warning"/> with the given exception, format string and arguments. | ||
/// </summary> | ||
public static void Warn(this ITracer tracer, Exception exception, string format, params object[] args) | ||
{ | ||
tracer.Trace(TraceEventType.Warning, exception, format, args); | ||
} | ||
|
||
#endregion | ||
|
||
#region Info overloads | ||
|
||
/// <summary> | ||
/// Traces an event of type <see cref="TraceEventType.Information"/> with the given message; | ||
/// </summary> | ||
public static void Info(this ITracer tracer, object message) | ||
{ | ||
tracer.Trace(TraceEventType.Information, message); | ||
} | ||
|
||
/// <summary> | ||
/// Traces an event of type <see cref="TraceEventType.Information"/> with the given format string and arguments. | ||
/// </summary> | ||
public static void Info(this ITracer tracer, string format, params object[] args) | ||
{ | ||
tracer.Trace(TraceEventType.Information, format, args); | ||
} | ||
|
||
/// <summary> | ||
/// Traces an event of type <see cref="TraceEventType.Information"/> with the given exception and message. | ||
/// </summary> | ||
public static void Info(this ITracer tracer, Exception exception, object message) | ||
{ | ||
tracer.Trace(TraceEventType.Information, exception, message); | ||
} | ||
|
||
/// <summary> | ||
/// Traces an event of type <see cref="TraceEventType.Information"/> with the given exception, format string and arguments. | ||
/// </summary> | ||
public static void Info(this ITracer tracer, Exception exception, string format, params object[] args) | ||
{ | ||
tracer.Trace(TraceEventType.Information, exception, format, args); | ||
} | ||
|
||
#endregion | ||
|
||
#region Verbose overloads | ||
|
||
/// <summary> | ||
/// Traces an event of type <see cref="TraceEventType.Verbose"/> with the given message; | ||
/// </summary> | ||
public static void Verbose(this ITracer tracer, object message) | ||
{ | ||
tracer.Trace(TraceEventType.Verbose, message); | ||
} | ||
|
||
/// <summary> | ||
/// Traces an event of type <see cref="TraceEventType.Verbose"/> with the given format string and arguments. | ||
/// </summary> | ||
public static void Verbose(this ITracer tracer, string format, params object[] args) | ||
{ | ||
tracer.Trace(TraceEventType.Verbose, format, args); | ||
} | ||
|
||
/// <summary> | ||
/// Traces an event of type <see cref="TraceEventType.Verbose"/> with the given exception and message. | ||
/// </summary> | ||
public static void Verbose(this ITracer tracer, Exception exception, object message) | ||
{ | ||
tracer.Trace(TraceEventType.Verbose, exception, message); | ||
} | ||
|
||
/// <summary> | ||
/// Traces an event of type <see cref="TraceEventType.Verbose"/> with the given exception, format string and arguments. | ||
/// </summary> | ||
public static void Verbose(this ITracer tracer, Exception exception, string format, params object[] args) | ||
{ | ||
tracer.Trace(TraceEventType.Verbose, exception, format, args); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
ReactiveSockets/External/Diagnostics/Tracer/ITracerManager.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,47 @@ | ||
#region BSD License | ||
/* | ||
Copyright (c) 2011, Clarius Consulting | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, this list | ||
of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, this | ||
list of conditions and the following disclaimer in the documentation and/or other | ||
materials provided with the distribution. | ||
* Neither the name of Clarius Consulting nor the names of its contributors may be | ||
used to endorse or promote products derived from this software without specific | ||
prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY | ||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT | ||
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED | ||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | ||
DAMAGE. | ||
*/ | ||
#endregion | ||
|
||
namespace ReactiveSockets.Diagnostics | ||
{ | ||
/// <summary> | ||
/// Manages <see cref="ITracer"/> instances. Provides the implementation | ||
/// for the <see cref="Tracer"/> static facade class. | ||
/// </summary> | ||
/// <nuget id="Tracer.Interfaces" /> | ||
partial interface ITracerManager | ||
{ | ||
/// <summary> | ||
/// Gets a tracer instance with the specified name. | ||
/// </summary> | ||
ITracer Get(string name); | ||
} | ||
} |
Oops, something went wrong.