@@ -72,7 +72,7 @@ public static Project GetAProject(string userName, string projectName)
72
72
var res = api . CreateProject ( userName , new ProjectCreate ( projectName , _public : ifPublic ) ) ;
73
73
return GetAProject ( userName , projectName ) ;
74
74
}
75
- Helper . Logger . Error ( e , $ "GetAProject: failed to get the project { userName } /{ projectName } ") ;
75
+ LogHelper . LogError ( e , $ "Failed to get the project { userName } /{ projectName } ") ;
76
76
throw e ;
77
77
}
78
78
@@ -90,8 +90,8 @@ public static Project GetWritableProject(string projectSlug)
90
90
91
91
public static async Task < bool > UploadDirectoryAsync ( Project project , string directory , Action < int > reportProgressAction = default , CancellationToken cancellationToken = default )
92
92
{
93
- Helper . Logger . Information ( $ "Uploading a directory { directory } ") ;
94
- Helper . Logger . Information ( $ "Timeout: { Configuration . Default . Timeout } ") ;
93
+ LogHelper . LogInfo ( $ "Uploading a directory { directory } ") ;
94
+ LogHelper . LogInfo ( $ "Timeout: { Configuration . Default . Timeout } ") ;
95
95
96
96
var files = Directory . GetFiles ( directory , "*" , SearchOption . AllDirectories ) ;
97
97
var api = new ArtifactsApi ( ) ;
@@ -100,7 +100,7 @@ public static async Task<bool> UploadDirectoryAsync(Project project, string dire
100
100
var tasks = files . Select ( _ => UploadArtifactAsync ( api , project , _ , _ . Replace ( directory , "" ) ) ) . ToList ( ) ;
101
101
var total = files . Count ( ) ;
102
102
103
- Helper . Logger . Information ( $ "UploadDirectoryAsync: Uploading { total } assets for project { project . Name } ") ;
103
+ LogHelper . LogInfo ( $ "Uploading { total } assets for project { project . Name } ") ;
104
104
105
105
106
106
var finishedPercent = 0 ;
@@ -111,15 +111,15 @@ public static async Task<bool> UploadDirectoryAsync(Project project, string dire
111
111
// canceled by user
112
112
if ( cancellationToken . IsCancellationRequested )
113
113
{
114
- Helper . Logger . Information ( $ "Canceled uploading by user") ;
114
+ LogHelper . LogInfo ( $ "Canceled uploading by user") ;
115
115
break ;
116
116
}
117
117
118
118
var finishedTask = await Task . WhenAny ( tasks ) ;
119
119
120
120
if ( finishedTask . IsFaulted || finishedTask . Exception != null )
121
121
{
122
- Helper . Logger . Error ( $ "Upload exception: { finishedTask . Exception } ") ;
122
+ LogHelper . LogError ( $ "Upload exception: { finishedTask . Exception } ") ;
123
123
throw finishedTask . Exception ;
124
124
}
125
125
@@ -130,7 +130,7 @@ public static async Task<bool> UploadDirectoryAsync(Project project, string dire
130
130
reportProgressAction ? . Invoke ( finishedPercent ) ;
131
131
132
132
}
133
- Helper . Logger . Information ( $ "UploadDirectoryAsync: Finished uploading assets for project { project . Name } ") ;
133
+ LogHelper . LogInfo ( $ "Finished uploading assets for project { project . Name } ") ;
134
134
135
135
// canceled by user
136
136
if ( cancellationToken . IsCancellationRequested ) return false ;
@@ -171,18 +171,18 @@ public static async Task<bool> UploadArtifactAsync(ArtifactsApi api, Project pro
171
171
172
172
restRequest . AddFile ( "file" , filePath ) ;
173
173
174
- Helper . Logger . Information ( $ "Started upload of { relativePath } ") ;
174
+ LogHelper . LogInfo ( $ "Started upload of { relativePath } ") ;
175
175
var response = await restClient . ExecuteAsync ( restRequest ) ;
176
176
177
177
if ( response . StatusCode == HttpStatusCode . NoContent )
178
178
{
179
- Helper . Logger . Information ( $ "UploadArtifaceAsync: Done uploading { fileRelativePath } ") ;
179
+ LogHelper . LogInfo ( $ "Done uploading { fileRelativePath } ") ;
180
180
return true ;
181
181
}
182
182
else
183
183
{
184
- Helper . Logger . Information ( $ "UploadArtifaceAsync: Received response code: { response . StatusCode } ") ;
185
- Helper . Logger . Information ( $ "{ response . Content } ") ;
184
+ LogHelper . LogInfo ( $ "Received response code: { response . StatusCode } ") ;
185
+ LogHelper . LogInfo ( $ "{ response . Content } ") ;
186
186
}
187
187
return false ;
188
188
}
@@ -504,13 +504,13 @@ public static async Task<string> DownloadArtifactAsync(ArtifactsApi api, string
504
504
505
505
var url = ( await api . DownloadArtifactAsync ( projOwner , projName , fileRelativePath ) ) ? . ToString ( ) ;
506
506
507
- Helper . Logger . Information ( $ "DownloadArtifactAsync: downloading { fileRelativePath } from \n -{ url } \n ") ;
507
+ LogHelper . LogInfo ( $ "Downloading { fileRelativePath } from \n -{ url } \n ") ;
508
508
// get relative path correct
509
509
saveAsDir = Path . GetDirectoryName ( Path . Combine ( saveAsDir , relativePath ) ) ;
510
510
saveAsDir = Path . GetFullPath ( saveAsDir ) ;
511
511
var path = await Helper . DownloadUrlAsync ( url . ToString ( ) , saveAsDir , reportProgressAction , null , cancelToken ) ;
512
512
513
- Helper . Logger . Information ( $ "DownloadArtifactAsync: saved { fileRelativePath } to { path } ") ;
513
+ LogHelper . LogInfo ( $ "Saved { fileRelativePath } to { path } ") ;
514
514
return path ;
515
515
}
516
516
@@ -522,13 +522,13 @@ public static async Task<string> DownloadArtifactAsync(JobsApi api, string projO
522
522
523
523
var url = ( await api . DownloadJobArtifactAsync ( projOwner , projName , jobId , fileRelativePath , cancelToken ) ) ? . ToString ( ) ;
524
524
525
- Helper . Logger . Information ( $ "DownloadJobArtifactAsync: downloading { fileRelativePath } from \n -{ url } \n ") ;
525
+ LogHelper . LogInfo ( $ "Downloading { fileRelativePath } from \n -{ url } \n ") ;
526
526
// get relative path correct
527
527
saveAsDir = Path . GetDirectoryName ( Path . Combine ( saveAsDir , relativePath ) ) ;
528
528
saveAsDir = Path . GetFullPath ( saveAsDir ) ;
529
529
var path = await Helper . DownloadUrlAsync ( url . ToString ( ) , saveAsDir , reportProgressAction , null , cancelToken ) ;
530
530
531
- Helper . Logger . Information ( $ "DownloadJobArtifactAsync: saved { fileRelativePath } to { path } ") ;
531
+ LogHelper . LogInfo ( $ "Saved { fileRelativePath } to { path } ") ;
532
532
return path ;
533
533
}
534
534
@@ -617,7 +617,7 @@ public static async Task<string> DownloadUrlAsync(string url, string saveAsDir,
617
617
618
618
Directory . CreateDirectory ( saveAsDir ) ;
619
619
var file = Path . Combine ( saveAsDir , fileName ) ;
620
- Helper . Logger . Information ( $ "DownloadUrlAsync: downloading { url } ") ;
620
+ LogHelper . LogInfo ( $ "Downloading { url } ") ;
621
621
using ( WebClient wc = new WebClient ( ) )
622
622
{
623
623
var prog = 0 ;
@@ -640,7 +640,7 @@ public static async Task<string> DownloadUrlAsync(string url, string saveAsDir,
640
640
await t ;
641
641
if ( t . IsFaulted && t . Exception != null )
642
642
throw t . Exception ;
643
- Helper . Logger . Information ( $ "DownloadUrlAsync: saved { fileName } to { file } ") ;
643
+ LogHelper . LogInfo ( $ "Saved { fileName } to { file } ") ;
644
644
}
645
645
catch ( WebException ex ) when ( ex . Status == WebExceptionStatus . RequestCanceled )
646
646
{
@@ -660,9 +660,7 @@ public static async Task<string> DownloadUrlAsync(string url, string saveAsDir,
660
660
661
661
if ( ! File . Exists ( file ) )
662
662
{
663
- var e = new ArgumentException ( $ "Failed to download { fileName } ") ;
664
- Helper . Logger . Error ( e , $ "DownloadFromUrlAsync: error") ;
665
- throw e ;
663
+ throw LogHelper . LogReturnError ( $ "Failed to download { fileName } ") ;
666
664
}
667
665
var outputDirOrFile = file ;
668
666
@@ -673,8 +671,7 @@ public static async Task<string> DownloadUrlAsync(string url, string saveAsDir,
673
671
}
674
672
catch ( Exception e )
675
673
{
676
- Helper . Logger . Error ( e , $ "DownloadFromUrlAsync: Unable to unzip file { Path . GetFileName ( file ) } ") ;
677
- throw new ArgumentException ( $ "Failed to unzip file { Path . GetFileName ( file ) } .\n -{ e . Message } ") ;
674
+ throw LogHelper . LogReturnError ( e , $ "Unable to unzip file { Path . GetFileName ( file ) } ") ;
678
675
}
679
676
680
677
return outputDirOrFile ;
0 commit comments