mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 05:23:31 -07:00
Added ProgressMessaging through nlog
This commit is contained in:
parent
3c632743a1
commit
780e374122
9 changed files with 128 additions and 12 deletions
|
@ -87,30 +87,32 @@ namespace NzbDrone.Common.Messaging
|
|||
_logger.Debug("{0} -> {1}", command.GetType().Name, handler.GetType().Name);
|
||||
|
||||
var sw = Stopwatch.StartNew();
|
||||
TrackedCommand queuedCommand = null;
|
||||
TrackedCommand trackedCommand = null;
|
||||
|
||||
try
|
||||
{
|
||||
queuedCommand = _trackCommands.TrackIfNew(command);
|
||||
trackedCommand = _trackCommands.TrackIfNew(command);
|
||||
|
||||
if (queuedCommand == null)
|
||||
if (trackedCommand == null)
|
||||
{
|
||||
_logger.Info("Command is already in progress: {0}", command.GetType().Name);
|
||||
return;
|
||||
}
|
||||
|
||||
MappedDiagnosticsContext.Set("CommandId", trackedCommand.Command.CommandId);
|
||||
|
||||
PublishEvent(new CommandStartedEvent(command));
|
||||
handler.Execute(command);
|
||||
sw.Stop();
|
||||
|
||||
_trackCommands.Completed(queuedCommand, sw.Elapsed);
|
||||
_trackCommands.Completed(trackedCommand, sw.Elapsed);
|
||||
PublishEvent(new CommandCompletedEvent(command));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (queuedCommand != null)
|
||||
if (trackedCommand != null)
|
||||
{
|
||||
_trackCommands.Failed(queuedCommand, e);
|
||||
_trackCommands.Failed(trackedCommand, e);
|
||||
}
|
||||
|
||||
PublishEvent(new CommandFailedEvent(command, e));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue