void LogEventListener( object sender, LogEventArgs e )
 {
     if( e.EntryType == LogEntryType.EventError )
     {
         ILogEventError eE = (ILogEventError)e;
         Assert.That( eE.Error.Message, Is.EqualTo( "Buggy handler..." ) );
         _exceptionLogged = true;
     }
 }
Exemplo n.º 2
0
        public VMOutputLogEntry( VMLogOutputContainer holder, LogEventArgs e, string message, int index )
        {
            _holder = holder;
            _logEventArgs = e;
            _isCreating = e.IsCreating;
            _message = message;
            _index = index;

            ILogInterceptionEntry logEntry = _logEventArgs as ILogInterceptionEntry;
            if( logEntry != null ) _category = logEntry.Member.DeclaringType.Name;
            else _category = "Other";
        }
Exemplo n.º 3
0
 void OnEventCreating( object sender, LogEventArgs e )
 {
     _buffer.GetStringBuilder().Length = 0;
     Process( _buffer, e );
     Log( e, _buffer.GetStringBuilder().ToString(), Common.Logging.LogLevel.Info );
 }
Exemplo n.º 4
0
 void OnEventCreated( object sender, LogEventArgs e )
 {
     _buffer.GetStringBuilder().Length = 0;
     NotifyError er = Process( _buffer, e );
     string message = _buffer.GetStringBuilder().ToString();
     if( er != null )
     {
         Log( e, message, Common.Logging.LogLevel.Error );
         bool errorLogCreated;
         using( var fileLog = CrashLogManager.CreateNew( "errorLog" ) )
         {
             errorLogCreated = fileLog.IsValid;
             fileLog.Writer.Write( message );
         }
         if( Notification != null )
         {
             if( !errorLogCreated && Notification != null )
             {
                 Notification.ShowNotification( PluginId.UniqueId, R.CriticalError, R.ErrorOccuredWhileLogging, 4000, NotificationTypes.Error );
             }
             else
             {
                 if( Notification != null )
                     Notification.ShowNotification( PluginId.UniqueId, er.Title, er.Content, 2000, NotificationTypes.Error );
                 PlanLogUpload();
             }
         }
     }
     else Log( e, message, Common.Logging.LogLevel.Info );
 }
Exemplo n.º 5
0
        private void Log( LogEventArgs e, string message, Common.Logging.LogLevel logLevel )
        {
            switch( logLevel )
            {
                case Common.Logging.LogLevel.Debug:
                    _log.Debug( message );
                    break;
                case Common.Logging.LogLevel.Error:
                    _log.Error( message );
                    break;
                case Common.Logging.LogLevel.Fatal:
                    _log.Fatal( message );
                    break;
                case Common.Logging.LogLevel.Info:
                case Common.Logging.LogLevel.Trace:
                    _log.Info( message );
                    break;
                case Common.Logging.LogLevel.Warn:
                    _log.Warn( message );
                    break;
                default:
                    _log.Info( message );
                    break;
            }

            //Enable other plugins to get formatted logs
            if( LogTriggered != null )
            {
                LogTriggered( this, new LogTriggeredEventArgs( e, message, logLevel.ToString() ) );
            }
        }
Exemplo n.º 6
0
 private static void WriteLineReturnValueAndCaller( TextWriter w, LogEventArgs e )
 {
     var m = e as ILogMethodEntry;
     if( m != null )
     {
         if( m.ReturnValue != null ) CrashLogWriter.WriteLineProperties( w, "Return Value", new object[] { m.ReturnValue.ToString() } );
         if( m.Caller != null ) CrashLogWriter.WriteLineProperties( w, "Caller", new object[] { m.Caller.ToString() } );
     }
 }
Exemplo n.º 7
0
 private static void WriteLineParameters( TextWriter w, LogEventArgs e )
 {
     var p = e as ILogWithParametersEntry;
     if( p != null )
     {
         if( p.Parameters != null && p.Parameters.Length > 0 ) CrashLogWriter.WriteLineProperties( w, "Parameters", p.Parameters );
     }
 }
Exemplo n.º 8
0
 private static void WriteLineMember( TextWriter w, LogEventArgs e )
 {
     var m = e as ILogInterceptionEntry;
     if( m != null )
     {
         CrashLogWriter.WriteLineProperty( w, "Member", m.Member.DeclaringType.Name + '.' + m.Member.Name );
     }
 }
Exemplo n.º 9
0
        private static NotifyError WriteLineError( TextWriter w, LogEventArgs e )
        {
            Debug.Assert( typeof( ILogErrorCulprit ).IsAssignableFrom( typeof( ILogEventNotRunningError ) )
                            && typeof( ILogErrorCulprit ).IsAssignableFrom( typeof( ILogErrorCaught ) ), "These 2 interfaces both are ILogErrorCulprit." );
            Debug.Assert( typeof( ILogErrorCaught ).IsAssignableFrom( typeof( ILogEventNotRunningError ) ) == false
                            && typeof( ILogEventNotRunningError ).IsAssignableFrom( typeof( ILogErrorCaught ) ) == false, "These 2 interfaces are independant." );

            var culprit = e as ILogErrorCulprit;
            if( culprit != null )
            {
                NotifyError notif = new NotifyError();
                notif.Title = String.Format( R.NotifiyErrorTitle, culprit.Culprit.DeclaringType.Name );

                CrashLogWriter.WriteLineProperty( w, "Culprit", culprit.Culprit.DeclaringType.FullName + '.' + culprit.Culprit.Name );
                var error = e as ILogErrorCaught;
                if( error != null )
                {
                    CrashLogWriter.WriteLineException( w, error.Error );
                    notif.Content = error.Error.Message;
                }
                else
                {
                    var runningError = e as ILogEventNotRunningError;
                    if( runningError != null )
                    {
                        CrashLogWriter.WriteLineProperty( w, "ServiceStatus", runningError.ServiceIsDisabled ? "Disabled" : "Stopped" );
                        notif.Content = R.ErrorEventServiceStatus;
                    }
                }
                return notif;
            }
            return null;
        }
Exemplo n.º 10
0
 /// <summary>
 /// Returns true if the event is an error (holds an exception).
 /// </summary>
 static NotifyError Process( TextWriter w, LogEventArgs e )
 {
     if( e.IsCreating )
     {
         w.NewLine = Environment.NewLine + new String( ' ', e.Depth );
         CrashLogWriter.WriteLineProperty( w, "Entering", e.GetType().Name );
         WriteLineMember( w, e );
         WriteLineParameters( w, e );
         WriteLineReturnValueAndCaller( w, e );
         return null;
     }
     else
     {
         CrashLogWriter.WriteLineProperty( w, "Log", e.GetType().Name );
         WriteLineMember( w, e );
         WriteLineParameters( w, e );
         WriteLineReturnValueAndCaller( w, e );
         NotifyError n = WriteLineError( w, e );
         w.NewLine = Environment.NewLine + new String( ' ', e.Depth );
         return n;
     }
 }
Exemplo n.º 11
0
 public void Add( LogEventArgs e, string message )
 {
     Add( new VMOutputLogEntry( this, e, message, ++_counter ) );
 }
Exemplo n.º 12
0
 public LogTriggeredEventArgs( LogEventArgs e, string content, string logLevel )
 {
     _logEventArgs = e;
     _content = content;
     _logLevel = logLevel;
 }