Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / MS / Internal / Utility / TraceLog.cs / 1305600 / 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
- InputScope.cs
- ComContractElementCollection.cs
- BoundingRectTracker.cs
- TextProviderWrapper.cs
- ConnectionConsumerAttribute.cs
- StaticFileHandler.cs
- FormsAuthenticationUserCollection.cs
- SerTrace.cs
- Italic.cs
- EntityViewGenerator.cs
- Confirm.cs
- ThrowHelper.cs
- ToolboxDataAttribute.cs
- ConfigurationLockCollection.cs
- TypeDescriptionProviderAttribute.cs
- MemoryFailPoint.cs
- XmlSchemaAnyAttribute.cs
- MasterPage.cs
- HttpModuleCollection.cs
- CookieParameter.cs
- Expr.cs
- SessionStateUtil.cs
- FileUpload.cs
- HttpListenerException.cs
- CurrencyManager.cs
- WebConfigurationHost.cs
- AppLevelCompilationSectionCache.cs
- Events.cs
- XmlNavigatorFilter.cs
- XmlLanguageConverter.cs
- _NegotiateClient.cs
- HandlerMappingMemo.cs
- IsolatedStorage.cs
- LogEntryDeserializer.cs
- DictionaryCustomTypeDescriptor.cs
- FakeModelItemImpl.cs
- GuidConverter.cs
- LostFocusEventManager.cs
- EmptyStringExpandableObjectConverter.cs
- XAMLParseException.cs
- TCPClient.cs
- StoreAnnotationsMap.cs
- ProxyWebPartConnectionCollection.cs
- BufferedWebEventProvider.cs
- DataGridViewLinkColumn.cs
- SettingsPropertyWrongTypeException.cs
- TileBrush.cs
- EmptyControlCollection.cs
- BindingElementCollection.cs
- AutomationEvent.cs
- XmlTextReader.cs
- WebException.cs
- CommandSet.cs
- UserControlParser.cs
- SectionRecord.cs
- DocumentAutomationPeer.cs
- AttachedAnnotation.cs
- DrawingAttributeSerializer.cs
- BufferModesCollection.cs
- parserscommon.cs
- NativeObjectSecurity.cs
- TextTreeTextNode.cs
- OleDbSchemaGuid.cs
- RequestCachePolicyConverter.cs
- ReferenceEqualityComparer.cs
- GenericPrincipal.cs
- ClientTarget.cs
- SqlReferenceCollection.cs
- MissingMemberException.cs
- XmlNamespaceManager.cs
- FixedDocumentSequencePaginator.cs
- EventHandlersDesigner.cs
- DataServiceQueryException.cs
- Mouse.cs
- XmlValidatingReader.cs
- WebConfigurationHostFileChange.cs
- TimeSpanValidatorAttribute.cs
- MetadataPropertyvalue.cs
- Enum.cs
- OutgoingWebResponseContext.cs
- Model3D.cs
- LinqToSqlWrapper.cs
- MyContact.cs
- WorkflowMarkupSerializationProvider.cs
- WeakEventTable.cs
- TraceSwitch.cs
- SignatureDescription.cs
- MediaScriptCommandRoutedEventArgs.cs
- MergeFailedEvent.cs
- MouseGesture.cs
- ModelServiceImpl.cs
- ActivityStatusChangeEventArgs.cs
- ArgumentNullException.cs
- PseudoWebRequest.cs
- TraceHandler.cs
- ExtensionDataReader.cs
- ParserExtension.cs
- MenuItemBinding.cs
- TriState.cs
- SqlConnectionStringBuilder.cs