Esempio n. 1
0
 /// <summary>
 /// Signals the launch of one or more dependent activities by emitting a log line that describes the token.
 /// The token must have been created by <see cref="CreateToken"/> or <see cref="CreateTokenWithTopic"/> with a true delayedLaunch parameter
 /// otherwise an <see cref="InvalidOperationException"/> is thrown.
 /// </summary>
 /// <param name="token">Dependent token.</param>
 public void Launch(ActivityMonitor.DependentToken token)
 {
     if (token.DelayedLaunchMessage == null)
     {
         throw new InvalidOperationException(Impl.ActivityMonitorResources.ActivityMonitorDependentTokenMustBeDelayedLaunch);
     }
     _monitor.UnfilteredLog(ActivityMonitor.Tags.CreateDependentActivity, LogLevel.Info, token.DelayedLaunchMessage, _monitor.NextLogTime(), null, _fileName, _lineNumber);
 }
            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));
            }
Esempio n. 3
0
 /// <summary>
 /// Starts a dependent activity. This sets the <see cref="ActivityMonitor.DependentToken.Topic"/> if it is not null and opens a group
 /// tagged with <see cref="ActivityMonitor.Tags.StartDependentActivity"/> with a message that can be parsed back thanks to <see cref="ActivityMonitor.DependentToken.TryParseStartMessage"/>.
 /// </summary>
 /// <param name="this">This <see cref="IActivityMonitor"/>.</param>
 /// <param name="token">Token that describes the origin of the activity.</param>
 /// <param name="fileName">Source file name of the emitter (automatically injected by C# compiler but can be explicitly set).</param>
 /// <param name="lineNumber">Line number in the source file (automatically injected by C# compiler but can be explicitly set).</param>
 /// <returns>A disposable object. It must be disposed at the end of the activity.</returns>
 static public IDisposable StartDependentActivity(this IActivityMonitor @this, ActivityMonitor.DependentToken token, [CallerFilePath] string fileName = null, [CallerLineNumber] int lineNumber = 0)
 {
     if (token == null)
     {
         throw new ArgumentNullException("token");
     }
     return(ActivityMonitor.DependentToken.Start(token, @this, fileName, lineNumber));
 }