Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / 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. //---------------------------------------------------------------------------- // //// 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
- HttpCacheVaryByContentEncodings.cs
- ThreadInterruptedException.cs
- CurrentChangedEventManager.cs
- CurrencyManager.cs
- Span.cs
- TypeCodeDomSerializer.cs
- _SingleItemRequestCache.cs
- DataGridViewAdvancedBorderStyle.cs
- DiagnosticStrings.cs
- SqlAliaser.cs
- OdbcCommandBuilder.cs
- XmlWriterDelegator.cs
- CatalogPartChrome.cs
- FormatConvertedBitmap.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- EmptyControlCollection.cs
- documentation.cs
- DetailsViewModeEventArgs.cs
- ApplicationHost.cs
- WinFormsSpinner.cs
- RuntimeEnvironment.cs
- SystemNetHelpers.cs
- StrongNameUtility.cs
- DocumentsTrace.cs
- TemplateField.cs
- DispatchChannelSink.cs
- PointLightBase.cs
- ExceptionHelpers.cs
- CodeTypeOfExpression.cs
- HttpProfileGroupBase.cs
- ValidatedControlConverter.cs
- Serializer.cs
- PageAsyncTask.cs
- TextEvent.cs
- ValidationEventArgs.cs
- VerificationAttribute.cs
- TextParaLineResult.cs
- RayMeshGeometry3DHitTestResult.cs
- COMException.cs
- MultipartContentParser.cs
- SafeLocalMemHandle.cs
- PackWebRequest.cs
- SqlInternalConnectionTds.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- RegexGroupCollection.cs
- XmlException.cs
- ColumnResizeUndoUnit.cs
- GrammarBuilderRuleRef.cs
- LinqToSqlWrapper.cs
- CachedFontFace.cs
- GuidConverter.cs
- SoapProtocolImporter.cs
- CommandTreeTypeHelper.cs
- ExecutionEngineException.cs
- PropertyMappingExceptionEventArgs.cs
- PreservationFileReader.cs
- ParseChildrenAsPropertiesAttribute.cs
- XmlValidatingReaderImpl.cs
- FacetEnabledSchemaElement.cs
- CheckBox.cs
- DetailsViewPageEventArgs.cs
- TagMapCollection.cs
- XmlProcessingInstruction.cs
- DependencySource.cs
- CodeEventReferenceExpression.cs
- XmlQueryRuntime.cs
- WorkflowRuntimeServiceElement.cs
- MessageBuffer.cs
- GridItemPatternIdentifiers.cs
- ObjectStateManagerMetadata.cs
- UrlPath.cs
- MenuAdapter.cs
- PropertySourceInfo.cs
- WebPartMenuStyle.cs
- DynamicILGenerator.cs
- Composition.cs
- ZipIORawDataFileBlock.cs
- XmlKeywords.cs
- DesignerLoader.cs
- DurableOperationContext.cs
- DiscoveryClientReferences.cs
- CompositeFontParser.cs
- RefreshEventArgs.cs
- ObjectListTitleAttribute.cs
- NativeMethodsOther.cs
- X509SecurityTokenProvider.cs
- SelectionRangeConverter.cs
- Comparer.cs
- FrameworkElement.cs
- IndicShape.cs
- WebScriptMetadataMessageEncodingBindingElement.cs
- SchemaManager.cs
- RegionInfo.cs
- LayoutTable.cs
- HelpKeywordAttribute.cs
- HttpRuntime.cs
- CacheVirtualItemsEvent.cs
- URLString.cs
- TextPattern.cs
- XslVisitor.cs