Ejemplo n.º 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();
        }
Ejemplo n.º 2
0
        internal static void PrintInfo(TraceSource traceSource, string msg)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Information))
            {
                return;
            }

            PrintLine(traceSource, TraceEventType.Information, 0, msg);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
0
 internal static void Exit(TraceSource traceSource, string msg)
 {
 }
Ejemplo n.º 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 + ")");
        }
Ejemplo n.º 7
0
 private static bool GetUseProtocolTextSetting(TraceSource traceSource)
 {
     return(DefaultUseProtocolTextOnly);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 9
0
 internal static void PrintError(TraceSource traceSource, string msg)
 {
 }
Ejemplo n.º 10
0
 internal static void PrintLine(TraceSource traceSource, TraceEventType eventType, int id, string msg)
 {
     traceSource.TraceEvent(eventType, id, ("[" + GetThreadId().ToString("d4", CultureInfo.InvariantCulture) + "] ") + msg);
 }
Ejemplo n.º 11
0
 internal static void PrintWarning(TraceSource traceSource, string msg)
 {
 }
Ejemplo n.º 12
0
 internal static void PrintInfo(TraceSource traceSource, string msg)
 {
 }
Ejemplo n.º 13
0
 internal static void Exit(TraceSource traceSource, string msg, string parameters)
 {
 }
Ejemplo n.º 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 + ")");
        }
Ejemplo n.º 15
0
 private static int GetMaxDumpSizeSetting(TraceSource traceSource)
 {
     return(DefaultMaxDumpSize);
 }
Ejemplo n.º 16
0
        internal static void PrintError(TraceSource traceSource, string msg)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Error))
            {
                return;
            }

            PrintLine(traceSource, TraceEventType.Error, 0, msg);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 19
0
 internal static bool IsVerbose(TraceSource traceSource)
 {
     return(ValidateSettings(traceSource, TraceEventType.Verbose));
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 21
0
 internal static void Enter(TraceSource traceSource, object obj, string method, object paramObject)
 {
 }
Ejemplo n.º 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 + ")");
        }
Ejemplo n.º 23
0
 internal static void Exit(TraceSource traceSource, object obj, string method, object retObject)
 {
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 25
0
 internal static void PrintWarning(TraceSource traceSource, object obj, string method, string msg)
 {
 }
Ejemplo n.º 26
0
        internal static void Exit(TraceSource traceSource, string method, string parameters)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Information))
            {
                return;
            }

            Exit(traceSource, method + "() " + parameters);
        }
Ejemplo n.º 27
0
 private static bool GetUseProtocolTextSetting(TraceSource traceSource)
 {
     return DefaultUseProtocolTextOnly;
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 29
0
 private static int GetMaxDumpSizeSetting(TraceSource traceSource)
 {
     return DefaultMaxDumpSize;
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 32
0
        internal static void PrintWarning(TraceSource traceSource, string msg)
        {
            if (!ValidateSettings(traceSource, TraceEventType.Warning))
            {
                return;
            }

            PrintLine(traceSource, TraceEventType.Warning, 0, msg);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 36
0
 internal static bool IsVerbose(TraceSource traceSource)
 {
     return ValidateSettings(traceSource, TraceEventType.Verbose);
 }
Ejemplo n.º 37
0
 internal static void Exception(TraceSource traceSource, object obj, string method, Exception e)
 {
 }
Ejemplo n.º 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);
        }