Skip to content

Commit 6f0126d

Browse files
committed
Add log error api function for csharp and jsonrpc
1 parent 0e4e95a commit 6f0126d

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

Flow.Launcher.Core/Plugin/JsonRPCV2Models/JsonRPCPublicAPI.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Flow.Launcher.Core.Plugin.JsonRPCV2Models
1212
{
1313
public class JsonRPCPublicAPI
1414
{
15-
private IPublicAPI _api;
15+
private readonly IPublicAPI _api;
1616

1717
public JsonRPCPublicAPI(IPublicAPI api)
1818
{
@@ -104,7 +104,6 @@ public List<PluginPair> GetAllPlugins()
104104
return _api.GetAllPlugins();
105105
}
106106

107-
108107
public MatchResult FuzzySearch(string query, string stringToCompare)
109108
{
110109
return _api.FuzzySearch(query, stringToCompare);
@@ -156,6 +155,11 @@ public void LogWarn(string className, string message, [CallerMemberName] string
156155
_api.LogWarn(className, message, methodName);
157156
}
158157

158+
public void LogError(string className, string message, [CallerMemberName] string methodName = "")
159+
{
160+
_api.LogError(className, message, methodName);
161+
}
162+
159163
public void OpenDirectory(string DirectoryPath, string FileNameOrFilePath = null)
160164
{
161165
_api.OpenDirectory(DirectoryPath, FileNameOrFilePath);

Flow.Launcher.Infrastructure/Logger/Log.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using System.Diagnostics;
22
using System.IO;
33
using System.Runtime.CompilerServices;
4+
using System.Runtime.ExceptionServices;
5+
using Flow.Launcher.Infrastructure.UserSettings;
46
using NLog;
57
using NLog.Config;
68
using NLog.Targets;
7-
using Flow.Launcher.Infrastructure.UserSettings;
89
using NLog.Targets.Wrappers;
9-
using System.Runtime.ExceptionServices;
1010

1111
namespace Flow.Launcher.Infrastructure.Logger
1212
{
@@ -135,13 +135,6 @@ private static string CheckClassAndMessageAndReturnFullClassWithMethod(string cl
135135
return className;
136136
}
137137

138-
private static void ExceptionInternal(string classAndMethod, string message, System.Exception e)
139-
{
140-
var logger = LogManager.GetLogger(classAndMethod);
141-
142-
logger.Error(e, message);
143-
}
144-
145138
private static void LogInternal(string message, LogLevel level)
146139
{
147140
if (FormatValid(message))

Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ public interface IPublicAPI
227227
/// </summary>
228228
void LogWarn(string className, string message, [CallerMemberName] string methodName = "");
229229

230+
/// <summary>
231+
/// Log error message
232+
/// </summary>
233+
void LogError(string className, string message, [CallerMemberName] string methodName = "");
234+
230235
/// <summary>
231236
/// Log an Exception. Will throw if in debug mode so developer will be aware,
232237
/// otherwise logs the eror message. This is the primary logging method used for Flow

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ public void LogInfo(string className, string message, [CallerMemberName] string
187187
public void LogWarn(string className, string message, [CallerMemberName] string methodName = "") =>
188188
Log.Warn(className, message, methodName);
189189

190+
public void LogError(string className, string message, [CallerMemberName] string methodName = "") =>
191+
Log.Error(className, message, methodName);
192+
190193
public void LogException(string className, string message, Exception e,
191194
[CallerMemberName] string methodName = "") => Log.Exception(className, message, e, methodName);
192195

0 commit comments

Comments
 (0)