7
7
using System . Threading ;
8
8
using System . Threading . Tasks ;
9
9
using Flow . Launcher . Core . Resource ;
10
- using Flow . Launcher . Infrastructure . Logger ;
11
10
using Flow . Launcher . Plugin ;
12
11
using Microsoft . IO ;
13
12
@@ -21,6 +20,8 @@ internal abstract class JsonRPCPlugin : JsonRPCPluginBase
21
20
{
22
21
public new const string JsonRPC = "JsonRPC" ;
23
22
23
+ private static readonly string ClassName = nameof ( JsonRPCPlugin ) ;
24
+
24
25
protected abstract Task < Stream > RequestAsync ( JsonRPCRequestModel rpcRequest , CancellationToken token = default ) ;
25
26
protected abstract string Request ( JsonRPCRequestModel rpcRequest , CancellationToken token = default ) ;
26
27
@@ -148,20 +149,20 @@ protected string Execute(ProcessStartInfo startInfo)
148
149
var error = standardError . ReadToEnd ( ) ;
149
150
if ( ! string . IsNullOrEmpty ( error ) )
150
151
{
151
- Log . Error ( $ "|JsonRPCPlugin.Execute| { error } " ) ;
152
+ Context . API . LogError ( ClassName , error ) ;
152
153
return string . Empty ;
153
154
}
154
155
155
- Log . Error ( "|JsonRPCPlugin.Execute| Empty standard output and standard error.") ;
156
+ Context . API . LogError ( ClassName , " Empty standard output and standard error.") ;
156
157
return string . Empty ;
157
158
}
158
159
159
160
return result ;
160
161
}
161
162
catch ( Exception e )
162
163
{
163
- Log . Exception (
164
- $ "|JsonRPCPlugin.Execute| Exception for filename <{ startInfo . FileName } > with argument <{ startInfo . Arguments } >",
164
+ Context . API . LogException ( ClassName ,
165
+ $ "Exception for filename <{ startInfo . FileName } > with argument <{ startInfo . Arguments } >",
165
166
e ) ;
166
167
return string . Empty ;
167
168
}
@@ -172,7 +173,7 @@ protected async Task<Stream> ExecuteAsync(ProcessStartInfo startInfo, Cancellati
172
173
using var process = Process . Start ( startInfo ) ;
173
174
if ( process == null )
174
175
{
175
- Log . Error ( "|JsonRPCPlugin.ExecuteAsync| Can't start new process") ;
176
+ Context . API . LogError ( ClassName , " Can't start new process") ;
176
177
return Stream . Null ;
177
178
}
178
179
@@ -192,7 +193,7 @@ protected async Task<Stream> ExecuteAsync(ProcessStartInfo startInfo, Cancellati
192
193
}
193
194
catch ( Exception e )
194
195
{
195
- Log . Exception ( "|JsonRPCPlugin.ExecuteAsync| Exception when kill process", e ) ;
196
+ Context . API . LogException ( ClassName , " Exception when kill process", e ) ;
196
197
}
197
198
} ) ;
198
199
@@ -213,7 +214,7 @@ protected async Task<Stream> ExecuteAsync(ProcessStartInfo startInfo, Cancellati
213
214
{
214
215
case ( 0 , 0 ) :
215
216
const string errorMessage = "Empty JSON-RPC Response." ;
216
- Log . Warn ( $ "| { nameof ( JsonRPCPlugin ) } . { nameof ( ExecuteAsync ) } | { errorMessage } " ) ;
217
+ Context . API . LogWarn ( ClassName , errorMessage ) ;
217
218
break ;
218
219
case ( _, not 0 ) :
219
220
throw new InvalidDataException ( Encoding . UTF8 . GetString ( errorBuffer . ToArray ( ) ) ) ; // The process has exited with an error message
0 commit comments