Example #1
0
        internal static void Exit(TraceSource traceSource, string msg)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Information))
            {
                return;
            }

            PrintLine(traceSource, TraceEventType.Verbose, 0, "Exiting " + msg);
            // Trace.CorrelationManager.StopLogicalOperation();
        }
Example #2
0
        internal static void PrintInfo(TraceSource traceSource, string msg)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Information))
            {
                return;
            }

            PrintLine(traceSource, TraceEventType.Information, 0, msg);
        }
Example #3
0
        internal static void Exit(TraceSource traceSource, string obj, string method, object retObject)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Information))
            {
                return;
            }

            string retValue = "";
            if (retObject != null)
            {
                retValue = GetObjectName(retObject) + "#" + Logging.HashString(retObject);
            }

            Exit(traceSource, obj, method, retValue);
        }
Example #4
0
        internal static void Exit(TraceSource traceSource, string obj, string method, string retValue)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Information))
            {
                return;
            }

            if (!string.IsNullOrEmpty(retValue))
            {
                retValue = "\t-> " + retValue;
            }

            Exit(traceSource, obj + "::" + method + "() " + retValue);
        }
Example #5
0
 internal static void Exit(TraceSource traceSource, string msg)
 {
 }
Example #6
0
        internal static void Enter(TraceSource traceSource, string obj, string method, string param)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Information))
            {
                return;
            }

            Enter(traceSource, obj + "::" + method + "(" + param + ")");
        }
Example #7
0
 private static bool GetUseProtocolTextSetting(TraceSource traceSource)
 {
     return(DefaultUseProtocolTextOnly);
 }
Example #8
0
        internal static void Dump(TraceSource traceSource, object obj, string method, IntPtr bufferPtr, int length)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Verbose) || bufferPtr == IntPtr.Zero || length < 0)
            {
                return;
            }

            byte[] buffer = new byte[length];
            Marshal.Copy(bufferPtr, buffer, 0, length);
            Dump(traceSource, obj, method, buffer, 0, length);
        }
Example #9
0
 internal static void PrintError(TraceSource traceSource, string msg)
 {
 }
 internal static void PrintLine(TraceSource traceSource, TraceEventType eventType, int id, string msg)
 {
     traceSource.TraceEvent(eventType, id, ("[" + GetThreadId().ToString("d4", CultureInfo.InvariantCulture) + "] ") + msg);
 }
Example #11
0
 internal static void PrintWarning(TraceSource traceSource, string msg)
 {
 }
Example #12
0
 internal static void PrintInfo(TraceSource traceSource, string msg)
 {
 }
Example #13
0
 internal static void Exit(TraceSource traceSource, string msg, string parameters)
 {
 }
Example #14
0
        internal static void PrintInfo(TraceSource traceSource, object obj, string method, string param)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Information))
            {
                return;
            }

            PrintLine(traceSource, TraceEventType.Information, 0,
                                   GetObjectName(obj) + "#" + Logging.HashString(obj)
                                   + "::" + method + "(" + param + ")");
        }
Example #15
0
 private static int GetMaxDumpSizeSetting(TraceSource traceSource)
 {
     return(DefaultMaxDumpSize);
 }
Example #16
0
        internal static void PrintError(TraceSource traceSource, string msg)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Error))
            {
                return;
            }

            PrintLine(traceSource, TraceEventType.Error, 0, msg);
        }
Example #17
0
        internal static void PrintLine(TraceSource traceSource, TraceEventType eventType, int id, string msg)
        {
            string logHeader = "[" + Environment.CurrentManagedThreadId.ToString("d4", CultureInfo.InvariantCulture) + "] ";

            traceSource.TraceEvent(eventType, id, logHeader + msg);
        }
Example #18
0
 internal static void PrintLine(TraceSource traceSource, TraceEventType eventType, int id, string msg)
 {
     string logHeader = "[" + Environment.CurrentManagedThreadId.ToString("d4", CultureInfo.InvariantCulture) + "] ";
     traceSource.TraceEvent(eventType, id, logHeader + msg);
 }
Example #19
0
 internal static bool IsVerbose(TraceSource traceSource)
 {
     return(ValidateSettings(traceSource, TraceEventType.Verbose));
 }
Example #20
0
        internal static void Enter(TraceSource traceSource, object obj, string method, object paramObject)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Information))
            {
                return;
            }

            Enter(traceSource, GetObjectName(obj) + "#" + Logging.HashString(obj), method, paramObject);
        }
Example #21
0
 internal static void Enter(TraceSource traceSource, object obj, string method, object paramObject)
 {
 }
Example #22
0
        internal static void Enter(TraceSource traceSource, string obj, string method, object paramObject)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Information))
            {
                return;
            }

            string paramObjectValue = "";
            if (paramObject != null)
            {
                paramObjectValue = GetObjectName(paramObject) + "#" + Logging.HashString(paramObject);
            }

            Enter(traceSource, obj + "::" + method + "(" + paramObjectValue + ")");
        }
Example #23
0
 internal static void Exit(TraceSource traceSource, object obj, string method, object retObject)
 {
 }
Example #24
0
        internal static void Exit(TraceSource traceSource, object obj, string method, string retValue)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Information))
            {
                return;
            }

            Exit(traceSource, GetObjectName(obj) + "#" + Logging.HashString(obj), method, retValue);
        }
Example #25
0
 internal static void PrintWarning(TraceSource traceSource, object obj, string method, string msg)
 {
 }
Example #26
0
        internal static void Exit(TraceSource traceSource, string method, string parameters)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Information))
            {
                return;
            }

            Exit(traceSource, method + "() " + parameters);
        }
Example #27
0
 private static bool GetUseProtocolTextSetting(TraceSource traceSource)
 {
     return DefaultUseProtocolTextOnly;
 }
Example #28
0
        internal static void Exception(TraceSource traceSource, object obj, string method, Exception e)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Error))
            {
                return;
            }

            string infoLine = SR.Format(SR.net_log_exception, GetObjectLogHash(obj), method, e.Message);
            if (!string.IsNullOrEmpty(e.StackTrace))
            {
                infoLine += Environment.NewLine + e.StackTrace;
            }

            PrintLine(traceSource, TraceEventType.Error, 0, infoLine);
        }
Example #29
0
 private static int GetMaxDumpSizeSetting(TraceSource traceSource)
 {
     return DefaultMaxDumpSize;
 }
Example #30
0
        internal static void PrintInfo(TraceSource traceSource, object obj, string msg)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Information))
            {
                return;
            }

            PrintLine(traceSource, TraceEventType.Information, 0,
                                   GetObjectName(obj) + "#" + Logging.HashString(obj)
                                   + " - " + msg);
        }
Example #31
0
        // Sets up internal config settings for logging.
        private static void InitializeLogging()
        {
            lock (InternalSyncObject)
            {
                if (!s_loggingInitialized)
                {
                    bool loggingEnabled = false;
                    s_webTraceSource = new NclTraceSource(TraceSourceWebName);
                    s_httpListenerTraceSource = new NclTraceSource(TraceSourceHttpListenerName);
                    s_socketsTraceSource = new NclTraceSource(TraceSourceSocketsName);
                    s_webSocketsTraceSource = new NclTraceSource(TraceSourceWebSocketsName);
                    s_cacheTraceSource = new NclTraceSource(TraceSourceCacheName);
                    s_traceSourceHttpName = new NclTraceSource(TraceSourceHttpName);

                    if (GlobalLog.IsEnabled)
                    {
                        GlobalLog.Print("Initalizating tracing");
                    }

                    try
                    {
                        loggingEnabled = (s_webTraceSource.Switch.ShouldTrace(TraceEventType.Critical) ||
                                          s_httpListenerTraceSource.Switch.ShouldTrace(TraceEventType.Critical) ||
                                          s_socketsTraceSource.Switch.ShouldTrace(TraceEventType.Critical) ||
                                          s_webSocketsTraceSource.Switch.ShouldTrace(TraceEventType.Critical) ||
                                          s_cacheTraceSource.Switch.ShouldTrace(TraceEventType.Critical) ||
                                          s_traceSourceHttpName.Switch.ShouldTrace(TraceEventType.Critical));
                    }
                    catch (SecurityException)
                    {
                        // These may throw if the caller does not have permission to hook up trace listeners.
                        // We treat this case as though logging were disabled.
                        Close();
                        loggingEnabled = false;
                    }

                    s_loggingEnabled = loggingEnabled;
                    s_loggingInitialized = true;
                }
            }
        }
Example #32
0
        internal static void PrintWarning(TraceSource traceSource, string msg)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Warning))
            {
                return;
            }

            PrintLine(traceSource, TraceEventType.Warning, 0, msg);
        }
Example #33
0
        // Confirms logging is enabled, given current logging settings
        private static bool ValidateSettings(TraceSource traceSource, TraceEventType traceLevel)
        {
            if (!s_loggingEnabled)
            {
                return false;
            }

            if (!s_loggingInitialized)
            {
                InitializeLogging();
            }

            if (traceSource == null || !traceSource.Switch.ShouldTrace(traceLevel))
            {
                return false;
            }

            return true;
        }
Example #34
0
        internal static void PrintError(TraceSource traceSource, object obj, string method, string msg)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Error))
            {
                return;
            }

            PrintLine(traceSource, TraceEventType.Error, 0,
                                   GetObjectName(obj) + "#" + Logging.HashString(obj)
                                   + "::" + method + "() - " + msg);
        }
Example #35
0
        internal static void Associate(TraceSource traceSource, object objA, object objB)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Information))
            {
                return;
            }

            string lineA = GetObjectName(objA) + "#" + Logging.HashString(objA);
            string lineB = GetObjectName(objB) + "#" + Logging.HashString(objB);

            PrintLine(traceSource, TraceEventType.Information, 0, "Associating " + lineA + " with " + lineB);
        }
Example #36
0
 internal static bool IsVerbose(TraceSource traceSource)
 {
     return ValidateSettings(traceSource, TraceEventType.Verbose);
 }
Example #37
0
 internal static void Exception(TraceSource traceSource, object obj, string method, Exception e)
 {
 }
Example #38
-7
        internal static void Dump(TraceSource traceSource, object obj, string method, byte[] buffer, int offset, int length)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Verbose))
            {
                return;
            }

            if (buffer == null)
            {
                PrintLine(traceSource, TraceEventType.Verbose, 0, "(null)");
                return;
            }

            if (offset > buffer.Length)
            {
                PrintLine(traceSource, TraceEventType.Verbose, 0, "(offset out of range)");
                return;
            }

            PrintLine(traceSource, TraceEventType.Verbose, 0, "Data from " + GetObjectName(obj) + "#" + Logging.HashString(obj) + "::" + method);
            int maxDumpSize = GetMaxDumpSizeSetting(traceSource);
            if (length > maxDumpSize)
            {
                PrintLine(traceSource, TraceEventType.Verbose, 0, "(printing " + maxDumpSize.ToString(NumberFormatInfo.InvariantInfo) + " out of " + length.ToString(NumberFormatInfo.InvariantInfo) + ")");
                length = maxDumpSize;
            }

            if ((length < 0) || (length > buffer.Length - offset))
            {
                length = buffer.Length - offset;
            }

            do
            {
                int n = Math.Min(length, 16);
                string disp = string.Format(CultureInfo.CurrentCulture, "{0:X8} : ", offset);
                for (int i = 0; i < n; ++i)
                {
                    disp += string.Format(CultureInfo.CurrentCulture, "{0:X2}", buffer[offset + i]) + ((i == 7) ? '-' : ' ');
                }

                for (int i = n; i < 16; ++i)
                {
                    disp += "   ";
                }

                disp += ": ";
                for (int i = 0; i < n; ++i)
                {
                    disp += ((buffer[offset + i] < 0x20) || (buffer[offset + i] > 0x7e))
                                ? '.'
                                : (char)(buffer[offset + i]);
                }

                PrintLine(traceSource, TraceEventType.Verbose, 0, disp);
                offset += n;
                length -= n;
            } while (length > 0);
        }