/// <summary>
        /// Writes an exception into one or more log entries, storing them in entries with a given prefix
        /// </summary>
        /// <param name="source">Log source</param>
        /// <param name="ex">Exception</param>
        /// <param name="entries">Log entry list</param>
        /// <param name="prefix">Entry string prefix</param>
        public static void ToLogEntries( Source source, Exception ex, IList< Entry > entries, string prefix )
        {
            if ( ex == null )
            {
                return;
            }
            StackTraceInfo info = new StackTraceInfo( ex.StackTrace );

            Entry baseEntry = new Entry( source, prefix + ex.Message );
            if ( info.HasMatch )
            {
                baseEntry.Locate( info.File, int.Parse( info.Line ), 1, info.Method );
                info.NextMatch( );
            }

            entries.Add( baseEntry );

            while ( info.HasMatch )
            {
                entries.Add( new Entry( source, prefix + "(call stack)" ).Locate( info.File, int.Parse( info.Line ), 1, info.Method ) );
                info.NextMatch( );
            }

            ToLogEntries( source, ex.InnerException, entries, prefix + "\t" );
        }
Exemplo n.º 2
0
 /// <summary>
 /// Setup constructor
 /// </summary>
 /// <param name="source">Message source</param>
 /// <param name="message">Message string</param>
 /// <param name="threadName">Thread source</param>
 /// <param name="time">Time that entry was generated</param>
 public Entry( Source source, string message, string threadName, TimeSpan time )
 {
     m_Source        = source;
     m_Message       = message;
     m_ThreadName    = threadName;
     m_Time          = time;
     m_Id            = m_MessageId++;
 }
        private const string kNewLine = "\r\n"; // <== GRRR

        #endregion Fields

        #region Methods

        /// <summary>
        /// Writes an exception into one or more log entries
        /// </summary>
        /// <param name="source">Log source</param>
        /// <param name="ex">Exception</param>
        public static void ToLog( Source source, Exception ex )
        {
            List< Entry > entries = new List< Entry >( );
            ToLogEntries( source, ex, entries );
            foreach ( Entry entry in entries )
            {
                Source.HandleEntry( entry );
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Setup constructor
        /// </summary>
        /// <param name="source">Message source</param>
        /// <param name="message">Message string</param>
        public Entry( Source source, string message )
        {
            m_Source        = source;
            m_Message       = message;
            m_ThreadName    = System.Threading.Thread.CurrentThread.Name;
            m_Time          = DateTime.Now.TimeOfDay;
            m_Id            = m_MessageId++;

            if ( string.IsNullOrEmpty( m_ThreadName ) )
            {
                m_ThreadName = System.Threading.Thread.CurrentThread.ManagedThreadId.ToString( );
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Construction helper
        /// </summary>
        /// <param name="parent">Parent tag</param>
        /// <param name="name">Tag name</param>
        private void Construct( Tag parent, string name )
        {
            m_Parent = parent;
            m_Name = name;
            m_Parent.m_ChildTags.Add( this );
            m_FullName = ( m_Parent.IsRootTag ? name : m_Parent.FullName + "." + name );

            for ( int severity = 0; severity < ( int )Severity.Count; ++severity )
            {
                m_DebugSources[ severity ]	= new DebugSource( this, ( Severity )severity );
                m_Sources[ severity ]		= new Source( this, ( Severity )severity );
            }
        }
 /// <summary>
 /// Writes an exception into one or more log entries, storing them in entries
 /// </summary>
 /// <param name="source">Log source</param>
 /// <param name="ex">Exception</param>
 /// <param name="entries">Log entry list</param>
 public static void ToLogEntries( Source source, Exception ex, IList< Entry > entries )
 {
     ToLogEntries( source, ex, entries, "" );
 }