Skip to content

Commit

Permalink
Fixed regression bug regarding logging within a secure service.
Browse files Browse the repository at this point in the history
  • Loading branch information
RxDave committed Jun 10, 2016
1 parent 53d10ec commit aed03ee
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 26 deletions.
8 changes: 4 additions & 4 deletions Source/Qactive/Log - Invocations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ namespace Qactive
{
static partial class Log
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObject(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObjectUnsafe(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[Conditional("TRACE")]
public static void Invoking(string name, object[] arguments, bool isServer, object sourceId, [CallerMemberName]string label = null)
#if TRACING
=> QactiveTraceSources.Qactive.SemanticObject(
=> QactiveTraceSources.Qactive.SemanticObjectUnsafe(
isServer
? SemanticTrace.ServerInvoking
: SemanticTrace.ClientServerInvoking,
Expand All @@ -23,11 +23,11 @@ public static void Invoking(string name, object[] arguments, bool isServer, obje
}
#endif

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObject(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObjectUnsafe(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[Conditional("TRACE")]
public static void Invoked(string name, object[] arguments, object returnValue, bool isServer, object sourceId, [CallerMemberName]string label = null)
#if TRACING
=> QactiveTraceSources.Qactive.SemanticObject(
=> QactiveTraceSources.Qactive.SemanticObjectUnsafe(
isServer
? SemanticTrace.ServerInvoked
: SemanticTrace.ClientServerInvoked,
Expand Down
20 changes: 10 additions & 10 deletions Source/Qactive/Log - Notifications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public static IObservable<TSource> TraceNotifications<TSource>(this IObservable<
#endif
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObject(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObjectUnsafe(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[Conditional("TRACE")]
public static void OnNext<T>(string observable, T value, bool isServer, bool isReceiving, object sourceId, [CallerMemberName]string label = null)
#if TRACING
=> QactiveTraceSources.Qactive.SemanticObject(
=> QactiveTraceSources.Qactive.SemanticObjectUnsafe(
isServer
? isReceiving
? SemanticTrace.ServerClientOnNext
Expand All @@ -45,11 +45,11 @@ public static void OnNext<T>(string observable, T value, bool isServer, bool isR
}
#endif

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObject(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObjectUnsafe(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[Conditional("TRACE")]
public static void OnError(string observable, Exception error, bool isServer, bool isReceiving, object sourceId, [CallerMemberName]string label = null)
#if TRACING
=> QactiveTraceSources.Qactive.SemanticObject(
=> QactiveTraceSources.Qactive.SemanticObjectUnsafe(
isServer
? isReceiving
? SemanticTrace.ServerClientOnError
Expand All @@ -66,11 +66,11 @@ public static void OnError(string observable, Exception error, bool isServer, bo
}
#endif

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObject(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObjectUnsafe(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[Conditional("TRACE")]
public static void OnCompleted(string observable, bool isServer, bool isReceiving, object sourceId, [CallerMemberName]string label = null)
#if TRACING
=> QactiveTraceSources.Qactive.SemanticObject(
=> QactiveTraceSources.Qactive.SemanticObjectUnsafe(
isServer
? isReceiving
? SemanticTrace.ServerClientOnCompleted
Expand All @@ -87,11 +87,11 @@ public static void OnCompleted(string observable, bool isServer, bool isReceivin
}
#endif

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObject(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObjectUnsafe(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[Conditional("TRACE")]
public static void MoveNext(string enumerable, bool isServer, object sourceId, [CallerMemberName]string label = null)
#if TRACING
=> QactiveTraceSources.Qactive.SemanticObject(
=> QactiveTraceSources.Qactive.SemanticObjectUnsafe(
isServer
? SemanticTrace.ServerMoveNext
: SemanticTrace.ClientServerMoveNext,
Expand All @@ -104,11 +104,11 @@ public static void MoveNext(string enumerable, bool isServer, object sourceId, [
}
#endif

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObject(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObjectUnsafe(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[Conditional("TRACE")]
public static void Current(string enumerable, object value, bool isServer, object sourceId, [CallerMemberName]string label = null)
#if TRACING
=> QactiveTraceSources.Qactive.SemanticObject(
=> QactiveTraceSources.Qactive.SemanticObjectUnsafe(
isServer
? SemanticTrace.ServerCurrent
: SemanticTrace.ClientServerCurrent,
Expand Down
24 changes: 12 additions & 12 deletions Source/Qactive/Log - Subscriptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public static IObservable<TSource> TraceSubscriptions<TSource>(this IObservable<
#endif
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObject(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObjectUnsafe(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[Conditional("TRACE")]
public static void Subscribing(string observable, bool isServer, bool isReceiving, object sourceId, [CallerMemberName]string label = null)
#if TRACING
=> QactiveTraceSources.Qactive.SemanticObject(
=> QactiveTraceSources.Qactive.SemanticObjectUnsafe(
isServer
? isReceiving
? SemanticTrace.ServerClientSubscribing
Expand All @@ -59,11 +59,11 @@ public static void Subscribing(string observable, bool isServer, bool isReceivin
}
#endif

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObject(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObjectUnsafe(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[Conditional("TRACE")]
public static void Subscribed(string observable, bool isServer, bool isReceiving, object sourceId, [CallerMemberName]string label = null)
#if TRACING
=> QactiveTraceSources.Qactive.SemanticObject(
=> QactiveTraceSources.Qactive.SemanticObjectUnsafe(
isServer
? isReceiving
? SemanticTrace.ServerClientSubscribed
Expand All @@ -80,11 +80,11 @@ public static void Subscribed(string observable, bool isServer, bool isReceiving
}
#endif

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObject(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObjectUnsafe(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[Conditional("TRACE")]
public static void Unsubscribing(string observable, bool isServer, bool isReceiving, object sourceId, [CallerMemberName]string label = null)
#if TRACING
=> QactiveTraceSources.Qactive.SemanticObject(
=> QactiveTraceSources.Qactive.SemanticObjectUnsafe(
isServer
? isReceiving
? SemanticTrace.ServerClientUnsubscribing
Expand All @@ -101,11 +101,11 @@ public static void Unsubscribing(string observable, bool isServer, bool isReceiv
}
#endif

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObject(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObjectUnsafe(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[Conditional("TRACE")]
public static void Unsubscribed(string observable, bool isServer, bool isReceiving, object sourceId, [CallerMemberName]string label = null)
#if TRACING
=> QactiveTraceSources.Qactive.SemanticObject(
=> QactiveTraceSources.Qactive.SemanticObjectUnsafe(
isServer
? isReceiving
? SemanticTrace.ServerClientUnsubscribed
Expand All @@ -122,11 +122,11 @@ public static void Unsubscribed(string observable, bool isServer, bool isReceivi
}
#endif

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObject(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObjectUnsafe(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[Conditional("TRACE")]
public static void Enumerating(string enumerable, bool isServer, object sourceId, [CallerMemberName]string label = null)
#if TRACING
=> QactiveTraceSources.Qactive.SemanticObject(
=> QactiveTraceSources.Qactive.SemanticObjectUnsafe(
isServer
? SemanticTrace.ServerEnumerating
: SemanticTrace.ClientServerEnumerating,
Expand All @@ -139,11 +139,11 @@ public static void Enumerating(string enumerable, bool isServer, object sourceId
}
#endif

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObject(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Qactive.Log.SemanticObjectUnsafe(System.Diagnostics.TraceSource,Qactive.SemanticTrace,System.Diagnostics.TraceEventType,System.Object,System.String,System.Object)", Justification = "It's just a separator.")]
[Conditional("TRACE")]
public static void Enumerated(string enumerable, bool isServer, object sourceId, [CallerMemberName]string label = null)
#if TRACING
=> QactiveTraceSources.Qactive.SemanticObject(
=> QactiveTraceSources.Qactive.SemanticObjectUnsafe(
isServer
? SemanticTrace.ServerEnumerated
: SemanticTrace.ClientServerEnumerated,
Expand Down
24 changes: 24 additions & 0 deletions Source/Qactive/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ private static void WriteLine(this TraceSource trace, FormattableString message)

trace.TraceEvent(TraceEventType.Error, 0, message?.ToString(CultureInfo.InvariantCulture));
}

/*
private static void Semantic(this TraceSource trace, SemanticTrace id, TraceEventType type, string message, object data)
{
Expand Down Expand Up @@ -102,12 +103,34 @@ private static void Semantic(this TraceSource trace, SemanticTrace id, TraceEven
trace.TraceEvent(type, (int)id, message?.ToString(CultureInfo.InvariantCulture));
}
*/

private static void SemanticObject(this TraceSource trace, SemanticTrace id, TraceEventType type, object objectId, string message, object data)
{
Contract.Requires(trace != null);

trace.TraceEvent(type, (int)id, FormatObjectId(objectId) + " " + message + " = " + data);
}

private static void SemanticObjectUnsafe(this TraceSource trace, SemanticTrace id, TraceEventType type, object objectId, string message, object data)
{
Contract.Requires(trace != null);

#if TRACING
new PermissionSet(PermissionState.Unrestricted).Assert();

try
{
#endif
SemanticObject(trace, id, type, objectId, message, data);
#if TRACING
}
finally
{
PermissionSet.RevertAssert();
}
#endif
}

/*
private static void SemanticObject(this TraceSource trace, SemanticTrace id, TraceEventType type, object objectId, string message)
{
Expand Down Expand Up @@ -144,6 +167,7 @@ private static void SemanticObject(this TraceSource trace, SemanticTrace id, Tra
trace.TraceEvent(type, (int)id, FormatObjectId(objectId) + " " + message?.ToString(CultureInfo.InvariantCulture));
}
*/

private static string FormatObjectId(object value)
=> "[" + (value?.ToString() ?? "?") + "]";
#endif
Expand Down

0 comments on commit aed03ee

Please sign in to comment.