Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Framework / MS / Internal / Utility / TraceLog.cs / 1 / TraceLog.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: Log of recent actions. Use this to debug those nasty problems // that don't repro on demand and don't have enough information in a crash // dump. // // In the class(es) of interest, add a TraceLog object. At points of // interest, call TraceLog.Add to record a string in the log. After the // crash, call TraceLog.WriteLog (or simply examine the log directly in // the debugger). Log entries are timestamped. // //--------------------------------------------------------------------------- using System; using System.Collections; using System.Globalization; namespace MS.Internal.Utility { internal class TraceLog { // create an unbounded trace log internal TraceLog() : this(Int32.MaxValue) {} // create a trace log that remembers the last 'size' actions internal TraceLog(int size) { _size = size; _log = new ArrayList(); } // add an entry to the log. Args are just like String.Format internal void Add(string message, params object[] args) { // create timestamped message string string s = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture) + " " + String.Format(CultureInfo.InvariantCulture, message, args); // if log is full, discard the oldest message if (_log.Count == _size) _log.RemoveAt(0); // add the new message _log.Add(s); } // write the log to the console internal void WriteLog() { for (int k=0; k<_log.Count; ++k) Console.WriteLine(_log[k]); } // return a printable id for the object internal static string IdFor(object o) { if (o == null) return "NULL"; else return String.Format(CultureInfo.InvariantCulture, "{0}.{1}", o.GetType().Name, o.GetHashCode()); } ArrayList _log; int _size; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PagesSection.cs
- NullableBoolConverter.cs
- NativeMethods.cs
- UserControl.cs
- HostAdapter.cs
- AgileSafeNativeMemoryHandle.cs
- ListDataBindEventArgs.cs
- ThrowOnMultipleAssignment.cs
- ServiceRouteHandler.cs
- FrameAutomationPeer.cs
- GeneralTransform.cs
- SourceFileInfo.cs
- FixedDocument.cs
- ReturnValue.cs
- TemplateEditingService.cs
- ExceptionUtil.cs
- TabletDeviceInfo.cs
- ScrollEvent.cs
- SynchronizedInputPattern.cs
- UseLicense.cs
- EFTableProvider.cs
- Opcode.cs
- HighContrastHelper.cs
- AbstractDataSvcMapFileLoader.cs
- ParameterElementCollection.cs
- QilSortKey.cs
- BitVector32.cs
- QueryException.cs
- CacheOutputQuery.cs
- EmbeddedMailObjectCollectionEditor.cs
- Debugger.cs
- Pair.cs
- ProfileServiceManager.cs
- NetworkInterface.cs
- SecurityKeyEntropyMode.cs
- COM2FontConverter.cs
- ParameterCollectionEditorForm.cs
- ThaiBuddhistCalendar.cs
- Highlights.cs
- WasHttpModulesInstallComponent.cs
- XPathException.cs
- HwndHostAutomationPeer.cs
- PieceNameHelper.cs
- NameValuePair.cs
- SynchronizationContext.cs
- UpdateTranslator.cs
- NavigationPropertyAccessor.cs
- ProfileEventArgs.cs
- __ConsoleStream.cs
- FontDialog.cs
- DataColumnMappingCollection.cs
- ToolStripItemImageRenderEventArgs.cs
- DataDocumentXPathNavigator.cs
- EncoderBestFitFallback.cs
- HttpRawResponse.cs
- Delegate.cs
- CodeIterationStatement.cs
- _emptywebproxy.cs
- LookupBindingPropertiesAttribute.cs
- ResourceDisplayNameAttribute.cs
- SoapSchemaImporter.cs
- DbDataRecord.cs
- PrintDialog.cs
- EventMetadata.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- XmlBindingWorker.cs
- PersistenceException.cs
- UiaCoreApi.cs
- Decoder.cs
- PreservationFileReader.cs
- CommandEventArgs.cs
- SafeViewOfFileHandle.cs
- Int16.cs
- MouseActionValueSerializer.cs
- ToolboxCategory.cs
- BindingMemberInfo.cs
- HtmlTable.cs
- PrimarySelectionAdorner.cs
- AspCompat.cs
- ElementProxy.cs
- WebConvert.cs
- EmulateRecognizeCompletedEventArgs.cs
- TextRunTypographyProperties.cs
- PatternMatcher.cs
- CodeVariableReferenceExpression.cs
- WebDisplayNameAttribute.cs
- DataGridViewCheckBoxColumn.cs
- BamlBinaryReader.cs
- RtType.cs
- JsonDeserializer.cs
- ToolStripDropTargetManager.cs
- FileUtil.cs
- PropertyFilterAttribute.cs
- CompilerTypeWithParams.cs
- X509Certificate2.cs
- SmiConnection.cs
- CheckBoxList.cs
- RewritingProcessor.cs
- InputLanguageProfileNotifySink.cs
- UnionCodeGroup.cs