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
- ConfigXmlElement.cs
- UnsafePeerToPeerMethods.cs
- MinMaxParagraphWidth.cs
- FormViewInsertedEventArgs.cs
- ViewKeyConstraint.cs
- XamlFilter.cs
- WebBrowserNavigatingEventHandler.cs
- ExpandedProjectionNode.cs
- TextSelectionHelper.cs
- AbstractSvcMapFileLoader.cs
- Stream.cs
- PauseStoryboard.cs
- StringKeyFrameCollection.cs
- NavigationProgressEventArgs.cs
- InvokePatternIdentifiers.cs
- Coordinator.cs
- Border.cs
- DataPagerField.cs
- ControlCollection.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- MissingFieldException.cs
- ModifierKeysValueSerializer.cs
- FixedHighlight.cs
- BitmapEffectDrawingContent.cs
- ObjectListGeneralPage.cs
- ImmComposition.cs
- SecurityChannelFaultConverter.cs
- DescendentsWalker.cs
- DataTableClearEvent.cs
- NativeMethods.cs
- DecimalConstantAttribute.cs
- StrokeSerializer.cs
- StructuredProperty.cs
- NativeCompoundFileAPIs.cs
- DataBindingCollection.cs
- Trace.cs
- ScaleTransform3D.cs
- Int16AnimationUsingKeyFrames.cs
- GeometryModel3D.cs
- ObjectToIdCache.cs
- MimeObjectFactory.cs
- DetailsViewUpdateEventArgs.cs
- LoginAutoFormat.cs
- MonthChangedEventArgs.cs
- OrderPreservingPipeliningMergeHelper.cs
- ResourceDescriptionAttribute.cs
- TypeInitializationException.cs
- SamlAction.cs
- ColumnCollectionEditor.cs
- TabItemAutomationPeer.cs
- RemoteWebConfigurationHost.cs
- Label.cs
- CellIdBoolean.cs
- XmlTextReaderImpl.cs
- TargetException.cs
- InnerItemCollectionView.cs
- SqlBooleanMismatchVisitor.cs
- AuthenticateEventArgs.cs
- Lease.cs
- SchemaImporterExtension.cs
- MouseActionConverter.cs
- BitSet.cs
- SByte.cs
- SqlDataSourceQueryEditor.cs
- FileUtil.cs
- XhtmlBasicControlAdapter.cs
- SQLGuidStorage.cs
- ResourceProviderFactory.cs
- InputLanguageProfileNotifySink.cs
- OdbcInfoMessageEvent.cs
- MessageBox.cs
- RtfFormatStack.cs
- EndpointConfigContainer.cs
- XmlSchemaSimpleContentExtension.cs
- XPathItem.cs
- SerializationSectionGroup.cs
- WmlTextBoxAdapter.cs
- PopupControlService.cs
- UnicodeEncoding.cs
- COM2ColorConverter.cs
- MiniModule.cs
- ToolStripItemCollection.cs
- BuilderInfo.cs
- Int32RectValueSerializer.cs
- ActivitySurrogate.cs
- TextStore.cs
- BamlCollectionHolder.cs
- DataGridSortCommandEventArgs.cs
- DesignerLoader.cs
- DataGridAddNewRow.cs
- JpegBitmapEncoder.cs
- ImageBrush.cs
- RegexParser.cs
- InertiaRotationBehavior.cs
- ValidationSummaryDesigner.cs
- XhtmlBasicObjectListAdapter.cs
- CodeDOMUtility.cs
- Debug.cs
- LoadGrammarCompletedEventArgs.cs
- FormViewInsertedEventArgs.cs