public override void TraceEventLogEvent(TraceEventType type, TraceRecord traceRecord) { switch (type) { case TraceEventType.Critical: if (TraceCore.TraceCodeEventLogCriticalIsEnabled(this)) { TraceCore.TraceCodeEventLogCritical(this, traceRecord); } break; case TraceEventType.Verbose: if (TraceCore.TraceCodeEventLogVerboseIsEnabled(this)) { TraceCore.TraceCodeEventLogVerbose(this, traceRecord); } break; case TraceEventType.Information: if (TraceCore.TraceCodeEventLogInfoIsEnabled(this)) { TraceCore.TraceCodeEventLogInfo(this, traceRecord); } break; case TraceEventType.Warning: if (TraceCore.TraceCodeEventLogWarningIsEnabled(this)) { TraceCore.TraceCodeEventLogWarning(this, traceRecord); } break; case TraceEventType.Error: if (TraceCore.TraceCodeEventLogErrorIsEnabled(this)) { TraceCore.TraceCodeEventLogError(this, traceRecord); } break; } }
void ShutdownTraceSource() { try { if (TraceCore.AppDomainUnloadIsEnabled(this)) { TraceCore.AppDomainUnload(this, AppDomain.CurrentDomain.FriendlyName, DiagnosticTraceBase.ProcessName, DiagnosticTraceBase.ProcessId.ToString(CultureInfo.CurrentCulture)); } this.TraceSource.Flush(); } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } //log failure LogTraceFailure(null, exception); } }
private void ChangeQuota(ref InternalBufferManager.PooledBufferManager.BufferPool bufferPool, int delta) { if (TraceCore.BufferPoolChangeQuotaIsEnabled(Fx.Trace)) { TraceCore.BufferPoolChangeQuota(Fx.Trace, bufferPool.BufferSize, delta); } InternalBufferManager.PooledBufferManager.BufferPool bufferPool2 = bufferPool; int num = bufferPool2.Limit + delta; InternalBufferManager.PooledBufferManager.BufferPool bufferPool3 = InternalBufferManager.PooledBufferManager.BufferPool.CreatePool(bufferPool2.BufferSize, num); for (int i = 0; i < num; i++) { byte[] array = bufferPool2.Take(); if (array == null) { break; } bufferPool3.Return(array); bufferPool3.IncrementCount(); } this.remainingMemory -= (long)(bufferPool2.BufferSize * delta); bufferPool = bufferPool3; }
private void ShutdownTraceSource() { try { if (TraceCore.AppDomainUnloadIsEnabled(this)) { int processId = DiagnosticTraceBase.ProcessId; TraceCore.AppDomainUnload(this, AppDomain.CurrentDomain.FriendlyName, DiagnosticTraceBase.ProcessName, processId.ToString(CultureInfo.CurrentCulture)); } base.TraceSource.Flush(); } catch (Exception exception1) { Exception exception = exception1; if (!Fx.IsFatal(exception)) { base.LogTraceFailure(null, exception); } else { throw; } } }
public override bool IsEnabled() { if (TraceCore.TraceCodeEventLogCriticalIsEnabled(this) || TraceCore.TraceCodeEventLogVerboseIsEnabled(this) || TraceCore.TraceCodeEventLogInfoIsEnabled(this) || TraceCore.TraceCodeEventLogWarningIsEnabled(this)) { return(true); } else { return(TraceCore.TraceCodeEventLogErrorIsEnabled(this)); } }
private void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args) { TraceCore.UnhandledException(this, (Exception)args.ExceptionObject); this.ShutdownTracing(); }
public void UnsafeLogEvent(TraceEventType type, ushort eventLogCategory, uint eventId, bool shouldTrace, params string[] values) { if (EventLogger.logCountForPT < 5) { try { int length = 0; string[] strArrays = new string[(int)values.Length + 2]; for (int i = 0; i < (int)values.Length; i++) { string str = values[i]; str = (string.IsNullOrEmpty(str) ? string.Empty : EventLogger.NormalizeEventLogParameter(str)); strArrays[i] = str; length = length + str.Length + 1; } string str1 = EventLogger.NormalizeEventLogParameter(EventLogger.UnsafeGetProcessName()); strArrays[(int)strArrays.Length - 2] = str1; length = length + str1.Length + 1; string str2 = EventLogger.UnsafeGetProcessId().ToString(CultureInfo.InvariantCulture); strArrays[(int)strArrays.Length - 1] = str2; length = length + str2.Length + 1; if (length > 25600) { int num = 25600 / (int)strArrays.Length - 1; for (int j = 0; j < (int)strArrays.Length; j++) { if (strArrays[j].Length > num) { strArrays[j] = strArrays[j].Substring(0, num); } } } SecurityIdentifier user = WindowsIdentity.GetCurrent().User; byte[] numArray = new byte[user.BinaryLength]; user.GetBinaryForm(numArray, 0); IntPtr[] intPtrArray = new IntPtr[(int)strArrays.Length]; GCHandle gCHandle = new GCHandle(); GCHandle[] gCHandleArray = null; try { gCHandle = GCHandle.Alloc(intPtrArray, GCHandleType.Pinned); gCHandleArray = new GCHandle[(int)strArrays.Length]; for (int k = 0; k < (int)strArrays.Length; k++) { gCHandleArray[k] = GCHandle.Alloc(strArrays[k], GCHandleType.Pinned); intPtrArray[k] = gCHandleArray[k].AddrOfPinnedObject(); } this.UnsafeWriteEventLog(type, eventLogCategory, eventId, strArrays, numArray, gCHandle); } finally { if (gCHandle.AddrOfPinnedObject() != IntPtr.Zero) { gCHandle.Free(); } if (gCHandleArray != null) { GCHandle[] gCHandleArray1 = gCHandleArray; for (int l = 0; l < (int)gCHandleArray1.Length; l++) { gCHandleArray1[l].Free(); } } } if (shouldTrace && this.diagnosticTrace != null && (TraceCore.TraceCodeEventLogCriticalIsEnabled(this.diagnosticTrace) || TraceCore.TraceCodeEventLogVerboseIsEnabled(this.diagnosticTrace) || TraceCore.TraceCodeEventLogInfoIsEnabled(this.diagnosticTrace) || TraceCore.TraceCodeEventLogWarningIsEnabled(this.diagnosticTrace) || TraceCore.TraceCodeEventLogErrorIsEnabled(this.diagnosticTrace))) { Dictionary <string, string> strs = new Dictionary <string, string>((int)strArrays.Length + 4); strs["CategoryID.Name"] = "EventLogCategory"; strs["CategoryID.Value"] = eventLogCategory.ToString(CultureInfo.InvariantCulture); strs["InstanceID.Name"] = "EventId"; strs["InstanceID.Value"] = eventId.ToString(CultureInfo.InvariantCulture); for (int m = 0; m < (int)values.Length; m++) { strs.Add(string.Concat("Value", m.ToString(CultureInfo.InvariantCulture)), (values[m] == null ? string.Empty : DiagnosticTrace.XmlEncode(values[m]))); } TraceRecord dictionaryTraceRecord = new DictionaryTraceRecord(strs); TraceEventType traceEventType = type; switch (traceEventType) { case TraceEventType.Critical: { TraceCore.TraceCodeEventLogCritical(this.diagnosticTrace, dictionaryTraceRecord); break; } case TraceEventType.Error: { TraceCore.TraceCodeEventLogError(this.diagnosticTrace, dictionaryTraceRecord); break; } case TraceEventType.Critical | TraceEventType.Error: { break; } case TraceEventType.Warning: { TraceCore.TraceCodeEventLogWarning(this.diagnosticTrace, dictionaryTraceRecord); break; } default: { if (traceEventType == TraceEventType.Information) { TraceCore.TraceCodeEventLogInfo(this.diagnosticTrace, dictionaryTraceRecord); break; } else if (traceEventType == TraceEventType.Verbose) { TraceCore.TraceCodeEventLogVerbose(this.diagnosticTrace, dictionaryTraceRecord); break; } else { break; } } } } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } } if (this.isInPartialTrust) { EventLogger.logCountForPT = EventLogger.logCountForPT + 1; } } }
protected override void OnUnhandledException(Exception exception) { TraceCore.UnhandledException(this, exception != null ? exception.ToString() : string.Empty, exception); }
public void SetAppUser(string appUser) { TraceCore.SetAppUser(appUser); }
public void Write(string loggerName, ExTicket ticket) { TraceCore.Write(loggerName, ticket); }
public void RegisterLogger(string loggerName) { TraceCore.RegisterLogger(loggerName); }
public void UnsafeLogEvent(TraceEventType type, ushort eventLogCategory, uint eventId, bool shouldTrace, params string[] values) { if (logCountForPT >= 5) { return; } try { int num = 0; string[] logValues = new string[values.Length + 2]; for (int i = 0; i < values.Length; i++) { string str = values[i]; if (!string.IsNullOrEmpty(str)) { str = NormalizeEventLogParameter(str); } else { str = string.Empty; } logValues[i] = str; num += str.Length + 1; } string str2 = NormalizeEventLogParameter(this.UnsafeGetProcessName()); logValues[logValues.Length - 2] = str2; num += str2.Length + 1; string str3 = this.UnsafeGetProcessId().ToString(CultureInfo.InvariantCulture); logValues[logValues.Length - 1] = str3; num += str3.Length + 1; if (num > 0x6400) { int length = (0x6400 / logValues.Length) - 1; for (int j = 0; j < logValues.Length; j++) { if (logValues[j].Length > length) { logValues[j] = logValues[j].Substring(0, length); } } } SecurityIdentifier user = WindowsIdentity.GetCurrent().User; byte[] binaryForm = new byte[user.BinaryLength]; user.GetBinaryForm(binaryForm, 0); IntPtr[] ptrArray = new IntPtr[logValues.Length]; GCHandle stringsRootHandle = new GCHandle(); GCHandle[] handleArray = null; try { stringsRootHandle = GCHandle.Alloc(ptrArray, GCHandleType.Pinned); handleArray = new GCHandle[logValues.Length]; for (int k = 0; k < logValues.Length; k++) { handleArray[k] = GCHandle.Alloc(logValues[k], GCHandleType.Pinned); ptrArray[k] = handleArray[k].AddrOfPinnedObject(); } this.UnsafeWriteEventLog(type, eventLogCategory, eventId, logValues, binaryForm, stringsRootHandle); } finally { if (stringsRootHandle.AddrOfPinnedObject() != IntPtr.Zero) { stringsRootHandle.Free(); } if (handleArray != null) { foreach (GCHandle handle2 in handleArray) { handle2.Free(); } } } if ((shouldTrace && (this.diagnosticTrace != null)) && ((TraceCore.TraceCodeEventLogCriticalIsEnabled(this.diagnosticTrace) || TraceCore.TraceCodeEventLogVerboseIsEnabled(this.diagnosticTrace)) || ((TraceCore.TraceCodeEventLogInfoIsEnabled(this.diagnosticTrace) || TraceCore.TraceCodeEventLogWarningIsEnabled(this.diagnosticTrace)) || TraceCore.TraceCodeEventLogErrorIsEnabled(this.diagnosticTrace)))) { Dictionary <string, string> dictionary = new Dictionary <string, string>(logValues.Length + 4); dictionary["CategoryID.Name"] = "EventLogCategory"; dictionary["CategoryID.Value"] = eventLogCategory.ToString(CultureInfo.InvariantCulture); dictionary["InstanceID.Name"] = "EventId"; dictionary["InstanceID.Value"] = eventId.ToString(CultureInfo.InvariantCulture); for (int m = 0; m < values.Length; m++) { dictionary.Add("Value" + m.ToString(CultureInfo.InvariantCulture), (values[m] == null) ? string.Empty : DiagnosticTrace.XmlEncode(values[m])); } TraceRecord traceRecord = new DictionaryTraceRecord(dictionary); switch (type) { case TraceEventType.Critical: TraceCore.TraceCodeEventLogCritical(this.diagnosticTrace, traceRecord); goto Label_035C; case TraceEventType.Error: TraceCore.TraceCodeEventLogError(this.diagnosticTrace, traceRecord); goto Label_035C; case (TraceEventType.Error | TraceEventType.Critical): goto Label_035C; case TraceEventType.Warning: TraceCore.TraceCodeEventLogWarning(this.diagnosticTrace, traceRecord); goto Label_035C; case TraceEventType.Information: TraceCore.TraceCodeEventLogInfo(this.diagnosticTrace, traceRecord); goto Label_035C; case TraceEventType.Verbose: TraceCore.TraceCodeEventLogVerbose(this.diagnosticTrace, traceRecord); goto Label_035C; } } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } } Label_035C: if (this.isInPartialTrust) { logCountForPT++; } }