Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Flow.Launcher.Core/Plugin/JsonRPCV2Models/JsonRPCPublicAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Flow.Launcher.Core.Plugin.JsonRPCV2Models
{
public class JsonRPCPublicAPI
{
private IPublicAPI _api;
private readonly IPublicAPI _api;

public JsonRPCPublicAPI(IPublicAPI api)
{
Expand Down Expand Up @@ -104,7 +104,6 @@ public List<PluginPair> GetAllPlugins()
return _api.GetAllPlugins();
}


public MatchResult FuzzySearch(string query, string stringToCompare)
{
return _api.FuzzySearch(query, stringToCompare);
Expand Down Expand Up @@ -156,6 +155,11 @@ public void LogWarn(string className, string message, [CallerMemberName] string
_api.LogWarn(className, message, methodName);
}

public void LogError(string className, string message, [CallerMemberName] string methodName = "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with the [CallerMemberName] syntax. Is that just apart of the typing of the methodName parameter?

How would this work for json-rpc plugins? Would they make a request like (this is a mockup, I don't remember the exact structure):

{
"method": "LogError",
"params": ["plugin_name", "traceback/stacktrace", "name of method that the plugin was handling"]
}

Copy link
Member Author

@Jack251970 Jack251970 Apr 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with the [CallerMemberName] syntax. Is that just apart of the typing of the methodName parameter?

How would this work for json-rpc plugins? Would they make a request like (this is a mockup, I don't remember the exact structure):

{
"method": "LogError",
"params": ["plugin_name", "traceback/stacktrace", "name of method that the plugin was handling"]
}

No sure how to use it, I think we need to manually pass methodName. Just ignore [CallMemberName] which should be used by csharp plugins only.

And usage is the same as LogInfo etc.

{
_api.LogError(className, message, methodName);
}

public void OpenDirectory(string DirectoryPath, string FileNameOrFilePath = null)
{
_api.OpenDirectory(DirectoryPath, FileNameOrFilePath);
Expand Down
11 changes: 2 additions & 9 deletions Flow.Launcher.Infrastructure/Logger/Log.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using Flow.Launcher.Infrastructure.UserSettings;
using NLog;
using NLog.Config;
using NLog.Targets;
using Flow.Launcher.Infrastructure.UserSettings;
using NLog.Targets.Wrappers;
using System.Runtime.ExceptionServices;

namespace Flow.Launcher.Infrastructure.Logger
{
Expand Down Expand Up @@ -135,13 +135,6 @@ private static string CheckClassAndMessageAndReturnFullClassWithMethod(string cl
return className;
}

private static void ExceptionInternal(string classAndMethod, string message, System.Exception e)
{
var logger = LogManager.GetLogger(classAndMethod);

logger.Error(e, message);
}

private static void LogInternal(string message, LogLevel level)
{
if (FormatValid(message))
Expand Down
5 changes: 5 additions & 0 deletions Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ public interface IPublicAPI
/// </summary>
void LogWarn(string className, string message, [CallerMemberName] string methodName = "");

/// <summary>
/// Log error message
/// </summary>
void LogError(string className, string message, [CallerMemberName] string methodName = "");

/// <summary>
/// Log an Exception. Will throw if in debug mode so developer will be aware,
/// otherwise logs the eror message. This is the primary logging method used for Flow
Expand Down
3 changes: 3 additions & 0 deletions Flow.Launcher/PublicAPIInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ public void LogInfo(string className, string message, [CallerMemberName] string
public void LogWarn(string className, string message, [CallerMemberName] string methodName = "") =>
Log.Warn(className, message, methodName);

public void LogError(string className, string message, [CallerMemberName] string methodName = "") =>
Log.Error(className, message, methodName);

public void LogException(string className, string message, Exception e,
[CallerMemberName] string methodName = "") => Log.Exception(className, message, e, methodName);

Expand Down
Loading