Skip to content

Commit 1210889

Browse files
mnicolescumnicolescu
mnicolescu
authored and
mnicolescu
committed
Add logging
1 parent 633825a commit 1210889

File tree

12 files changed

+36
-3
lines changed

12 files changed

+36
-3
lines changed

ProcessMyMedia.Samples/Program.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace ProcessMyMedia.Samples
22
{
3-
using System;
43
using System.IO;
54

65
using Microsoft.Extensions.Configuration;
@@ -16,7 +15,7 @@ static void Main(string[] args)
1615

1716
IConfigurationRoot configuration = builder.Build();
1817

19-
new Samples.AnalyseAsset(configuration).Execute();
18+
new Samples.IngestFromDirectory(configuration).Execute();
2019
}
2120
}
2221
}

ProcessMyMedia/Tasks/Data/CopyTask.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ protected async override Task<ExecutionResult> RunTaskAsync(IStepExecutionContex
127127
}
128128
};
129129

130+
this.logger.LogDebug($"Create the pipeline for the Copy Task");
131+
130132
await this.service.CreateOrUpdatePipelineyAsync(pipeline);
131133

132134
runID = await this.service.RunPipelineAsync(pipeline.Name);
@@ -141,6 +143,7 @@ protected async override Task<ExecutionResult> RunTaskAsync(IStepExecutionContex
141143
if (!this.Output.Run.IsFinished
142144
|| context.PersistenceData == null)
143145
{
146+
this.logger.LogInformation("The copy is in progress.");
144147
return ExecutionResult.Sleep(this.delayService.GetTimeToSleep(this.Output.Run.StartDate), this.Output);
145148
}
146149
else if (this.Output.Run.OnError)

ProcessMyMedia/Tasks/Data/CreateLinkedServiceTask.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ protected override void ValidateInput()
6767
/// <returns></returns>
6868
protected async override Task<ExecutionResult> RunTaskAsync(IStepExecutionContext context)
6969
{
70+
this.logger.LogInformation($"Create the Linked service {this.LinkedServiceToCreate.Name}");
71+
7072
await this.service.CreateOrUpdateLinkedServiceAsync(
7173
this.LinkedServiceToCreate.Name,
7274
this.LinkedServiceToCreate.Type,

ProcessMyMedia/Tasks/Media/Analyzing/AnalyzeFileTask.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ protected async override Task RunMediaAnalyseTaskAsync(IStepExecutionContext con
5757
{
5858
string assetName = $"input-{Guid.NewGuid()}";
5959

60+
this.logger.LogInformation($"Create the asset {assetName}");
61+
6062
var asset = await service.CreateOrUpdateAssetAsync(assetName);
6163

64+
this.logger.LogDebug($"Upload the file {this.FilePath} for the asset {this.AssetName}");
65+
6266
await service.UploadFilesToAssetAsync(assetName, new[] { this.FilePath });
6367

6468
this.AssetName = assetName;

ProcessMyMedia/Tasks/Media/Analyzing/AnalyzeTaskBase.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ protected override async Task<ExecutionResult> RunTaskAsync(IStepExecutionContex
6363
{
6464
//First call: stat analyse
6565
await this.RunMediaAnalyseTaskAsync(context);
66+
67+
this.logger.LogInformation($"Start analyse the asset {this.AssetName}");
68+
6669
job = await this.service.StartAnalyseAsync(this.AssetName, this.AnalyzingParameters);
6770
}
6871
else
@@ -75,6 +78,7 @@ protected override async Task<ExecutionResult> RunTaskAsync(IStepExecutionContex
7578
if (!job.IsFinished)
7679
{
7780
this.logger.LogInformation($"Analysing progress : {job.Progress} %");
81+
7882
return ExecutionResult.Sleep(this.delayService.GetTimeToSleep(job.Created), job);
7983
}
8084
else if (job.Canceled)

ProcessMyMedia/Tasks/Media/Asset/DeleteAssetTask.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ protected override void ValidateInput()
5252
/// <returns></returns>
5353
protected override async Task<ExecutionResult> RunTaskAsync(IStepExecutionContext context)
5454
{
55+
this.logger.LogInformation($"Delete the asset {this.AssetName}");
56+
5557
await this.service.DeleteAssetAsync(this.AssetName);
5658

5759
return ExecutionResult.Next();

ProcessMyMedia/Tasks/Media/Asset/DownloadAssetTask.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ protected override void ValidateInput()
6767
/// <returns></returns>
6868
protected async override Task<ExecutionResult> RunTaskAsync(IStepExecutionContext context)
6969
{
70+
this.logger.LogInformation($"Upload files from the asset {this.AssetName} to {this.DirectoryToDownload}");
71+
7072
await this.service.DownloadFilesAsync(this.AssetName, this.DirectoryToDownload);
7173

7274
return ExecutionResult.Next();

ProcessMyMedia/Tasks/Media/Asset/IngestFilesTaskBase.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ protected override async Task<ExecutionResult> RunTaskAsync(IStepExecutionContex
6767
{
6868
await base.RunTaskAsync(context);
6969

70+
this.logger.LogDebug($"Upload {this.AssetFiles.Count} files for the asset {this.AssetName}");
71+
7072
await this.service.UploadFilesToAssetAsync(this.AssetName, this.AssetFiles, this.Metadata);
7173

7274
return ExecutionResult.Next();

ProcessMyMedia/Tasks/Media/Asset/IngestTask.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ protected override void ValidateInput()
6767
/// <returns></returns>
6868
protected async override Task<ExecutionResult> RunTaskAsync(IStepExecutionContext context)
6969
{
70+
this.logger.LogInformation($"Create the asset {this.AssetName}");
71+
7072
AssetEntity asset = await this.service.CreateOrUpdateAssetAsync(this.AssetName,
7173
assetDescription: this.AssetDescription,
7274
storageAccountName: this.StorageAccountName);

ProcessMyMedia/Tasks/Media/Encoding/EncodeFileTaskBase.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,12 @@ protected override async Task RunMediaEncodingTaskAsync(IStepExecutionContext co
6464
{
6565
string assetName = $"input-{Guid.NewGuid()}";
6666

67+
this.logger.LogInformation($"Create the encoding input asset {assetName} for the file {this.FilePath}");
68+
6769
var asset = await service.CreateOrUpdateAssetAsync(assetName);
6870

71+
this.logger.LogInformation($"Upload the file {this.FilePath} for the asset {assetName}");
72+
6973
await service.UploadFilesToAssetAsync(assetName, new[] { this.FilePath });
7074

7175
this.Inputs.Add (new JobInputEntity(){ Name = assetName});

ProcessMyMedia/Tasks/Media/Encoding/EncodeTaskBase.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ protected override async Task<ExecutionResult> RunTaskAsync(IStepExecutionContex
7777
{
7878
//First call: start encoding
7979
await this.RunMediaEncodingTaskAsync(context);
80+
81+
this.logger.LogInformation("Start encoding");
82+
8083
job = await this.service.StartEncodeAsync(this.Inputs, this.Outputs, this.Priority);
8184
}
8285
else

ProcessMyMedia/Tasks/TaskBase.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,25 @@ public override async Task<ExecutionResult> RunAsync(IStepExecutionContext conte
5050

5151
try
5252
{
53+
this.logger.LogDebug($"Task {this.GetType().Name} started");
54+
5355
var result = await this.RunTaskAsync(context);
5456

5557
if (this.CleanupResources && !result.SleepFor.HasValue)
5658
{
5759
await this.Cleanup(context);
5860
}
5961

62+
this.logger.LogDebug($"Task {this.GetType().Name} completed");
63+
6064
return result;
6165
}
62-
catch
66+
catch(Exception exc)
6367
{
6468
this.onError = true;
6569

70+
this.logger.LogError($"Task {this.GetType().Name} terminated with error {exc}");
71+
6672
if (this.CleanupResources)
6773
{
6874
await this.Cleanup(context);

0 commit comments

Comments
 (0)