Data required by IActivityMonitor.UnfilteredLog. This is also the base class for ActivityMonitorGroupData.
        void IActivityMonitorClient.OnUnfilteredLog( ActivityMonitorLogData data )
        {
            var level = data.MaskedLevel;

            if( !CanOutputLine( level ) )
            {
                return;
            }

            if( data.Text == ActivityMonitor.ParkLevel )
            {
                if( _curLevel != -1 )
                {
                    OnLeaveLevel( (LogLevel)_curLevel );
                }
                _curLevel = -1;
            }
            else
            {
                if( _curLevel == (int)level )
                {
                    OnContinueOnSameLevel( data );
                }
                else
                {
                    if( _curLevel != -1 )
                    {
                        OnLeaveLevel( (LogLevel)_curLevel );
                    }
                    OnEnterLevel( data );
                    _curLevel = (int)level;
                }
            }
        }
예제 #2
0
        void IActivityMonitorClient.OnUnfilteredLog(ActivityMonitorLogData data)
        {
            var level = data.MaskedLevel;

            if (!CanOutputLine(level))
            {
                return;
            }

            if (data.Text == ActivityMonitor.ParkLevel)
            {
                if (_curLevel != -1)
                {
                    OnLeaveLevel((LogLevel)_curLevel);
                }
                _curLevel = -1;
            }
            else
            {
                if (_curLevel == (int)level)
                {
                    OnContinueOnSameLevel(data);
                }
                else
                {
                    if (_curLevel != -1)
                    {
                        OnLeaveLevel((LogLevel)_curLevel);
                    }
                    OnEnterLevel(data);
                    _curLevel = (int)level;
                }
            }
        }
예제 #3
0
 protected override void OnContinueOnSameLevel( ActivityMonitorLogData data )
 {
     Entries.Add( new Entry( data ) );
     Writer.Write( data.Text );
     if( WriteTags ) Writer.Write( "-[{0}]", data.Tags.ToString() );
     if( data.Exception != null ) Writer.Write( "Exception: " + data.Exception.Message );
 }
예제 #4
0
 public Entry( ActivityMonitorLogData d )
 {
     Level = d.Level;
     Tags = d.Tags;
     Text = d.Text;
     Exception = d.Exception;
     LogTime = d.LogTime;
 }
예제 #5
0
 protected override void OnEnterLevel( ActivityMonitorLogData data )
 {
     Entries.Add( new Entry( data ) );
     Writer.WriteLine();
     Writer.Write( data.MaskedLevel.ToString() + ": " + data.Text );
     if( WriteTags ) Writer.Write( "-[{0}]", data.Tags.ToString() );
     if( data.Exception != null ) Writer.Write( "Exception: " + data.Exception.Message );
 }
        /// <summary>
        /// Appends any log with level equal or above <see cref="MinimalFilter"/> to <see cref="Entries"/>.
        /// </summary>
        /// <param name="data">Log data. Never null.</param>
        void IActivityMonitorClient.OnUnfilteredLog(ActivityMonitorLogData data)
        {
            var level = data.Level & LogLevel.Mask;

            if ((int)level >= (int)_filter)
            {
                _entries.Push(new Entry(data.Tags, level, data.Text, data.LogTime, data.Exception));
            }
        }
예제 #7
0
 public void OnUnfilteredLog( ActivityMonitorLogData data )
 {
     var level = data.Level & LogLevel.Mask;
     if( level >= LogLevel.Error )
     {
         string s = DumpErrorText( data.LogTime, data.Text, data.Level, null, data.Tags );
         SystemActivityMonitor.HandleError( s );
     }
 }
예제 #8
0
            public void OnUnfilteredLog(ActivityMonitorLogData data)
            {
                var level = data.Level & LogLevel.Mask;

                if (level >= LogLevel.Error)
                {
                    string s = DumpErrorText(data.LogTime, data.Text, data.Level, null, data.Tags);
                    SystemActivityMonitor.HandleError(s);
                }
            }
 public void OnUnfilteredLog(ActivityMonitorLogData data)
 {
     if (data.MaskedLevel == LogLevel.Error)
     {
         _onError();
     }
     else if (data.MaskedLevel == LogLevel.Fatal)
     {
         _onFatal();
     }
 }
 public void OnUnfilteredLog(ActivityMonitorLogData data)
 {
     if (data.MaskedLevel >= _minLogLevel)
     {
         _tc.TrackTrace(data.Text, GetSeverityLevel(data));
     }
     if (data.Exception != null)
     {
         _tc.TrackException(data.Exception);
     }
 }
예제 #11
0
        void IActivityMonitorClient.OnUnfilteredLog(ActivityMonitorLogData data)
        {
            // If the level is above the actual target filter, we always send the message.
            // If the level is lower: if the log has not been filtered (UnfilteredLog has been called and not an extension method) we must
            // send it to honor the "Unfiltered" contract, but if _applyTargetFilterToUnfilteredLogs is true, we avoid sending it.
            var level = data.Level;

            if (((level & LogLevel.IsFiltered) == 0 && !_applyTargetFilterToUnfilteredLogs) || (int)GetActualTargetFilter().Line <= (int)(level & LogLevel.Mask))
            {
                _targetMonitor.UnfilteredLog(data);
            }
        }
예제 #12
0
 /// <summary>
 /// Logs a text regardless of <see cref="MinimalFilter"/> level (except for <see cref="LogLevelFilter.Off"/>).
 /// Each call to log is considered as a unit of text: depending on the rendering engine, a line or a
 /// paragraph separator (or any appropriate separator) should be appended between each text if
 /// the level is the same as the previous one.
 /// See remarks.
 /// </summary>
 /// <param name="data">Data that describes the log. Can not be null.</param>
 /// <remarks>
 /// A null or empty <see cref="ActivityMonitorLogData.Text"/> is not logged.
 /// If needed, the special text <see cref="ActivityMonitor.ParkLevel"/> ("PARK-LEVEL") breaks the current <see cref="LogLevel"/>
 /// and resets it: the next log, even with the same LogLevel, will be treated as if
 /// a different LogLevel is used.
 /// </remarks>
 public void UnfilteredLog(ActivityMonitorLogData data)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     ReentrantAndConcurrentCheck();
     try
     {
         DoUnfilteredLog(data);
     }
     finally
     {
         ReentrantAndConcurrentRelease();
     }
 }
예제 #13
0
        void DoUnfilteredLog(ActivityMonitorLogData data)
        {
            Debug.Assert(_enteredThreadId == Thread.CurrentThread.ManagedThreadId);
            Debug.Assert(data.Level != LogLevel.None);
            Debug.Assert(!String.IsNullOrEmpty(data.Text));

            if (!data.IsFilteredLog)
            {
                if (_actualFilterIsDirty)
                {
                    DoResyncActualFilter();
                }
                if (_actualFilter.Line == LogLevelFilter.Off)
                {
                    return;
                }
            }

            _lastLogTime = data.CombineTagsAndAdjustLogTime(_currentTag, _lastLogTime);
            List <IActivityMonitorClient> buggyClients = null;

            foreach (var l in _output.Clients)
            {
                try
                {
                    l.OnUnfilteredLog(data);
                }
                catch (Exception exCall)
                {
                    CriticalErrorCollector.Add(exCall, l.GetType().FullName);
                    if (buggyClients == null)
                    {
                        buggyClients = new List <IActivityMonitorClient>();
                    }
                    buggyClients.Add(l);
                }
            }
            if (buggyClients != null)
            {
                foreach (var l in buggyClients)
                {
                    _output.ForceRemoveBuggyClient(l);
                }
                _clientFilter = DoGetBoundClientMinimalFilter();
                UpdateActualFilter();
            }
        }
        /// <summary>
        /// Writes all information.
        /// </summary>
        /// <param name="data">Log data.</param>
        protected override void OnContinueOnSameLevel( ActivityMonitorLogData data )
        {
            var w = _buffer.Clear();
            w.AppendMultiLine( _prefixLevel, data.Text, true );
            if( _currentTags != data.Tags )
            {
                w.Append( " -[" ).Append( data.Tags ).Append( ']' );
                _currentTags = data.Tags;
            }
            w.AppendLine();
            if( data.Exception != null )
            {
                DumpException( w, _prefix, !data.IsTextTheExceptionMessage, data.Exception );
            }

            _writer( _buffer.ToString() );
        }
        /// <summary>
        /// Writes all information.
        /// </summary>
        /// <param name="data">Log data.</param>
        protected override void OnContinueOnSameLevel(ActivityMonitorLogData data)
        {
            var w = _buffer.Clear();

            w.AppendMultiLine(_prefixLevel, data.Text, true);
            if (_currentTags != data.Tags)
            {
                w.Append(" -[").Append(data.Tags).Append(']');
                _currentTags = data.Tags;
            }
            w.AppendLine();
            if (data.Exception != null)
            {
                DumpException(w, _prefix, !data.IsTextTheExceptionMessage, data.Exception);
            }

            _writer(_buffer.ToString());
        }
예제 #16
0
 /// <summary>
 /// Appends or updates the last <see cref="PathElement"/> of <see cref="DynamicPath"/>
 /// and handles errors or warning.
 /// </summary>
 /// <param name="data">Log data. Never null.</param>
 protected override void OnUnfilteredLog(ActivityMonitorLogData data)
 {
     if (data.Text != ActivityMonitor.ParkLevel)
     {
         if (_currentIsGroupClosed)
         {
             HandleCurrentGroupIsClosed();
         }
         if (_currentIsGroup || _current == null)
         {
             _current = new PathElement();
             _path.Add(_current);
             _currentIsGroup = false;
         }
         _current.Tags        = data.Tags;
         _current.MaskedLevel = data.Level & LogLevel.Mask;
         _current.Text        = data.Text;
         CheckSnapshot();
     }
 }
        /// <summary>
        /// Writes all the information.
        /// </summary>
        /// <param name="data">Log data.</param>
        protected override void OnEnterLevel( ActivityMonitorLogData data )
        {
            var w = _buffer.Clear();
            _prefixLevel = _prefix + new string( ' ', data.MaskedLevel.ToString().Length + 4 );

            w.Append( _prefix )
                .Append( "- " )
                .Append( data.MaskedLevel.ToString() )
                .Append( ": " )
                .AppendMultiLine( _prefixLevel, data.Text, false );

            if( _currentTags != data.Tags )
            {
                w.Append( " -[" ).Append( data.Tags ).Append( ']' );
                _currentTags = data.Tags;
            }
            w.AppendLine();
            if( data.Exception != null )
            {
                DumpException( w, _prefix, !data.IsTextTheExceptionMessage, data.Exception );
            }
            _writer( w.ToString() );
        }
        /// <summary>
        /// Writes all the information.
        /// </summary>
        /// <param name="data">Log data.</param>
        protected override void OnEnterLevel(ActivityMonitorLogData data)
        {
            var w = _buffer.Clear();

            _prefixLevel = _prefix + new string( ' ', data.MaskedLevel.ToString().Length + 4 );

            w.Append(_prefix)
            .Append("- ")
            .Append(data.MaskedLevel.ToString())
            .Append(": ")
            .AppendMultiLine(_prefixLevel, data.Text, false);

            if (_currentTags != data.Tags)
            {
                w.Append(" -[").Append(data.Tags).Append(']');
                _currentTags = data.Tags;
            }
            w.AppendLine();
            if (data.Exception != null)
            {
                DumpException(w, _prefix, !data.IsTextTheExceptionMessage, data.Exception);
            }
            _writer(w.ToString());
        }
        private static SeverityLevel GetSeverityLevel(ActivityMonitorLogData data)
        {
            switch (data.MaskedLevel)
            {
            case LogLevel.Debug:
            case LogLevel.Trace:
                return(SeverityLevel.Verbose);

            case LogLevel.Info:
                return(SeverityLevel.Information);

            case LogLevel.Warn:
                return(SeverityLevel.Warning);

            case LogLevel.Error:
                return(SeverityLevel.Error);

            case LogLevel.Fatal:
                return(SeverityLevel.Critical);

            default:
                return(SeverityLevel.Information);
            }
        }
예제 #20
0
 /// <summary>
 /// Called for each <see cref="IActivityMonitor.UnfilteredLog"/>. Does nothing by default.
 /// The <see cref="ActivityMonitorLogData.Exception"/> is always null since exceptions
 /// are carried by groups.
 /// </summary>
 /// <param name="data">Log data. Never null.</param>
 protected virtual void OnUnfilteredLog(ActivityMonitorLogData data)
 {
 }
예제 #21
0
 /// <summary>
 /// Called for each <see cref="IActivityMonitor.UnfilteredLog"/>. Does nothing by default.
 /// The <see cref="ActivityMonitorLogData.Exception"/> is always null since exceptions
 /// are carried by groups.
 /// </summary>
 /// <param name="data">Log data. Never null.</param>
 protected virtual void OnUnfilteredLog( ActivityMonitorLogData data )
 {
 }
예제 #22
0
 void IActivityMonitorClient.OnUnfilteredLog(ActivityMonitorLogData data)
 {
     OnUnfilteredLog(data);
 }
예제 #23
0
 void IActivityMonitorClient.OnUnfilteredLog( ActivityMonitorLogData data )
 {
     if( _file != null )
     {
         _file.UnicastWrite( data, this );
         _prevlogTime = data.LogTime;
         _prevLogType = LogEntryType.Line;
     }
 }
예제 #24
0
 void IActivityMonitorClient.OnUnfilteredLog( ActivityMonitorLogData data )
 {
     OnUnfilteredLog( data );
 }
 /// <summary>
 /// Appends or updates the last <see cref="PathElement"/> of <see cref="DynamicPath"/>
 /// and handles errors or warning.
 /// </summary>
 /// <param name="data">Log data. Never null.</param>
 protected override void OnUnfilteredLog( ActivityMonitorLogData data )
 {
     if( data.Text != ActivityMonitor.ParkLevel )
     {
         if( _currentIsGroupClosed ) HandleCurrentGroupIsClosed();
         if( _currentIsGroup || _current == null )
         {
             _current = new PathElement();
             _path.Add( _current );
             _currentIsGroup = false;
         }
         _current.Tags = data.Tags;
         _current.MaskedLevel = data.Level&LogLevel.Mask;
         _current.Text = data.Text;
         CheckSnapshot();
     }
 }
 /// <summary>
 /// Called for the first text of a <see cref="LogLevel"/>.
 /// </summary>
 /// <param name="data">Log data.</param>
 protected abstract void OnEnterLevel( ActivityMonitorLogData data );
예제 #27
0
 public void OnUnfilteredLog( ActivityMonitorLogData data )
 {
     MayFail();
 }
예제 #28
0
 protected override void OnEnterLevel( ActivityMonitorLogData data )
 {
     XmlWriter.WriteStartElement( data.MaskedLevel.ToString() );
     XmlWriter.WriteString( data.Text );
 }
예제 #29
0
 /// <summary>
 /// Called for text with the same <see cref="LogLevel"/> as the previous ones.
 /// </summary>
 /// <param name="data">Log data.</param>
 protected abstract void OnContinueOnSameLevel(ActivityMonitorLogData data);
예제 #30
0
 /// <summary>
 /// Called for the first text of a <see cref="LogLevel"/>.
 /// </summary>
 /// <param name="data">Log data.</param>
 protected abstract void OnEnterLevel(ActivityMonitorLogData data);
예제 #31
0
 void IActivityMonitorClient.OnUnfilteredLog( ActivityMonitorLogData data )
 {
     // If the level is above the actual target filter, we always send the message.
     // If the level is lower: if the log has not been filtered (UnfilteredLog has been called and not an extension method) we must
     // send it to honor the "Unfiltered" contract, but if _applyTargetFilterToUnfilteredLogs is true, we avoid sending it.
     var level = data.Level;
     if( ((level & LogLevel.IsFiltered) == 0 && !_applyTargetFilterToUnfilteredLogs) || (int)GetActualTargetFilter().Line <= (int)(level & LogLevel.Mask) )
     {
         _targetMonitor.UnfilteredLog( data );
     }
 }
 /// <summary>
 /// Appends any log with level equal or above <see cref="MinimalFilter"/> to <see cref="Entries"/>.
 /// </summary>
 /// <param name="data">Log data. Never null.</param>
 void IActivityMonitorClient.OnUnfilteredLog( ActivityMonitorLogData data )
 {
     var level = data.Level & LogLevel.Mask;
     if( (int)level >= (int)_filter )
     {
         _entries.Push( new Entry( data.Tags, level, data.Text, data.LogTime, data.Exception ) );
     }
 }
예제 #33
0
 protected override void OnContinueOnSameLevel( ActivityMonitorLogData data )
 {
     XmlWriter.WriteString( data.Text );
 }
 /// <summary>
 /// Updates error counters.
 /// </summary>
 /// <param name="data">Log data. Never null.</param>
 protected override void OnUnfilteredLog(ActivityMonitorLogData data)
 {
     _current.CatchLevel(data.Level & LogLevel.Mask);
 }
예제 #35
0
 void IActivityMonitorClient.OnUnfilteredLog( ActivityMonitorLogData data )
 {
     var h = EnsureChannel();
     if( h != null )
     {
         IMulticastLogEntry e = LogEntry.CreateMulticastLog( _monitorSource.UniqueId, _prevLogType, _prevlogTime, _currentGroupDepth, data.Text, data.LogTime, data.Level, data.FileName, data.LineNumber, data.Tags, data.EnsureExceptionData() );
         h.Handle( new GrandOutputEventInfo( e, _monitorSource.Topic ) );
         _prevlogTime = data.LogTime;
         _prevLogType = LogEntryType.Line;
     }
 }
 /// <summary>
 /// Called for text with the same <see cref="LogLevel"/> as the previous ones.
 /// </summary>
 /// <param name="data">Log data.</param>
 protected abstract void OnContinueOnSameLevel( ActivityMonitorLogData data );
예제 #37
0
 public void OnUnfilteredLog( ActivityMonitorLogData data )
 {
     lock( _buffer ) _buffer.Append( _prefix ).AppendFormat( "[{0}]{1}", data.Level, data.Text ).AppendLine();
 }
 /// <summary>
 /// Updates error counters.
 /// </summary>
 /// <param name="data">Log data. Never null.</param>
 protected override void OnUnfilteredLog( ActivityMonitorLogData data )
 {
     _current.CatchLevel( data.Level&LogLevel.Mask );
 }
예제 #39
0
 /// <summary>
 /// Writes a line entry as a uni-cast compact entry or as a multi-cast one if needed.
 /// </summary>
 /// <param name="data">The log line.</param>
 /// <param name="adapter">Multi-cast information to be able to write multi-cast entry when needed.</param>
 public void UnicastWrite( ActivityMonitorLogData data, IMulticastLogInfo adapter )
 {
     BeforeWrite();
     LogEntry.WriteLog( _writer, adapter.MonitorId, adapter.PreviousEntryType, adapter.PreviousLogTime, adapter.GroupDepth, false, data.Level, data.LogTime, data.Text, data.Tags, data.ExceptionData, data.FileName, data.LineNumber );
     AfterWrite();
 }