コード例 #1
0
            static internal IDisposable Start(ActivityMonitor.DependentToken token, IActivityMonitor monitor, string fileName, int lineNumber)
            {
                string msg = token.FormatStartMessage();

                if (token.Topic != null)
                {
                    string currentTopic = token.Topic;
                    monitor.SetTopic(token.Topic, fileName, lineNumber);
                    var g = monitor.UnfilteredOpenGroup(ActivityMonitor.Tags.StartDependentActivity, LogLevel.Info, null, msg, monitor.NextLogTime(), null, fileName, lineNumber);
                    return(Util.CreateDisposableAction(() => { g.Dispose(); monitor.SetTopic(currentTopic, fileName, lineNumber); }));
                }
                return(monitor.UnfilteredOpenGroup(ActivityMonitor.Tags.StartDependentActivity, LogLevel.Info, null, msg, monitor.NextLogTime(), null, fileName, lineNumber));
            }
コード例 #2
0
 bool DoSomething(IActivityMonitor m, FileInfo file)
 {
     using (m.OpenInfo().Send("Do something important on file '{0}'.", file.Name))
     {
         if (!file.Exists)
         {
             m.Warn().Send("File does not exist.");
         }
         else
         {
             m.Trace().Send("File last modified at {1:T}. {0} Kb to process.", file.Length, file.LastWriteTimeUtc);
             try
             {
                 // ... Process file ...
             }
             catch (Exception ex)
             {
                 m.Error().Send(ex, "While processing.");
                 return(false);
             }
         }
         m.SetTopic("Changing my mind. Keeping it as-is.");
         return(true);
     }
 }
コード例 #3
0
 bool DoSomething( IActivityMonitor m, FileInfo file )
 {
     using( m.OpenInfo().Send( "Do something important on file '{0}'.", file.Name ) )
     {
         if( !file.Exists )
         {
             m.Warn().Send( "File does not exist." );
         }
         else
         {
             m.Trace().Send( "File last modified at {1:T}. {0} Kb to process.", file.Length, file.LastWriteTimeUtc );
             try
             {
                 // ... Process file ...
             }
             catch( Exception ex )
             {
                 m.Error().Send( ex, "While processing." );
                 return false;
             }
         }
         m.SetTopic( "Changing my mind. Keeping it as-is." );
         return true;
     }
 }
コード例 #4
0
 static internal IDisposable Start( ActivityMonitor.DependentToken token, IActivityMonitor monitor, string fileName, int lineNumber )
 {
     string msg = token.FormatStartMessage();
     if( token.Topic != null )
     {
         string currentTopic = token.Topic;
         monitor.SetTopic( token.Topic, fileName, lineNumber );
         var g = monitor.UnfilteredOpenGroup( ActivityMonitor.Tags.StartDependentActivity, LogLevel.Info, null, msg, monitor.NextLogTime(), null, fileName, lineNumber );
         return Util.CreateDisposableAction( () => { g.Dispose(); monitor.SetTopic( currentTopic, fileName, lineNumber ); } );
     }
     return monitor.UnfilteredOpenGroup( ActivityMonitor.Tags.StartDependentActivity, LogLevel.Info, null, msg, monitor.NextLogTime(), null, fileName, lineNumber );
 }