Skip to content

Commit 43dbf1a

Browse files
committed
Remove useless functions & Fix debug issue
1 parent 20d2661 commit 43dbf1a

File tree

3 files changed

+7
-69
lines changed

3 files changed

+7
-69
lines changed

Flow.Launcher.Core/Plugin/PluginsLoader.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,19 @@ private static IEnumerable<PluginPair> DotNetPlugins(List<PluginMetadata> source
8989
#else
9090
catch (Exception e) when (assembly == null)
9191
{
92-
Log.Exception($"|PluginsLoader.DotNetPlugins|Couldn't load assembly for the plugin: {metadata.Name}", e);
92+
Log.Exception(ClassName, $"Couldn't load assembly for the plugin: {metadata.Name}", e);
9393
}
9494
catch (InvalidOperationException e)
9595
{
96-
Log.Exception($"|PluginsLoader.DotNetPlugins|Can't find the required IPlugin interface for the plugin: <{metadata.Name}>", e);
96+
Log.Exception(ClassName, $"Can't find the required IPlugin interface for the plugin: <{metadata.Name}>", e);
9797
}
9898
catch (ReflectionTypeLoadException e)
9999
{
100-
Log.Exception($"|PluginsLoader.DotNetPlugins|The GetTypes method was unable to load assembly types for the plugin: <{metadata.Name}>", e);
100+
Log.Exception(ClassName, $"The GetTypes method was unable to load assembly types for the plugin: <{metadata.Name}>", e);
101101
}
102102
catch (Exception e)
103103
{
104-
Log.Exception($"|PluginsLoader.DotNetPlugins|The following plugin has errored and can not be loaded: <{metadata.Name}>", e);
104+
Log.Exception(ClassName, $"The following plugin has errored and can not be loaded: <{metadata.Name}>", e);
105105
}
106106
#endif
107107

Flow.Launcher.Infrastructure/Logger/Log.cs

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,6 @@ private static void LogFaultyFormat(string message)
9494
logger.Fatal(message);
9595
}
9696

97-
private static bool FormatValid(string message)
98-
{
99-
var parts = message.Split('|');
100-
var valid = parts.Length == 3 && !string.IsNullOrWhiteSpace(parts[1]) && !string.IsNullOrWhiteSpace(parts[2]);
101-
return valid;
102-
}
103-
10497
public static void Exception(string className, string message, System.Exception exception, [CallerMemberName] string methodName = "")
10598
{
10699
exception = exception.Demystify();
@@ -135,57 +128,14 @@ private static string CheckClassAndMessageAndReturnFullClassWithMethod(string cl
135128
return className;
136129
}
137130

131+
#if !DEBUG
138132
private static void ExceptionInternal(string classAndMethod, string message, System.Exception e)
139133
{
140134
var logger = LogManager.GetLogger(classAndMethod);
141135

142136
logger.Error(e, message);
143137
}
144-
145-
private static void LogInternal(string message, LogLevel level)
146-
{
147-
if (FormatValid(message))
148-
{
149-
var parts = message.Split('|');
150-
var prefix = parts[1];
151-
var unprefixed = parts[2];
152-
var logger = LogManager.GetLogger(prefix);
153-
logger.Log(level, unprefixed);
154-
}
155-
else
156-
{
157-
LogFaultyFormat(message);
158-
}
159-
}
160-
161-
/// Example: "|ClassName.MethodName|Message"
162-
/// <param name="message">Example: "|ClassName.MethodName|Message" </param>
163-
/// <param name="e">Exception</param>
164-
public static void Exception(string message, System.Exception e)
165-
{
166-
e = e.Demystify();
167-
#if DEBUG
168-
ExceptionDispatchInfo.Capture(e).Throw();
169-
#else
170-
if (FormatValid(message))
171-
{
172-
var parts = message.Split('|');
173-
var prefix = parts[1];
174-
var unprefixed = parts[2];
175-
ExceptionInternal(prefix, unprefixed, e);
176-
}
177-
else
178-
{
179-
LogFaultyFormat(message);
180-
}
181138
#endif
182-
}
183-
184-
/// Example: "|ClassName.MethodName|Message"
185-
public static void Error(string message)
186-
{
187-
LogInternal(message, LogLevel.Error);
188-
}
189139

190140
public static void Error(string className, string message, [CallerMemberName] string methodName = "")
191141
{
@@ -206,23 +156,11 @@ public static void Debug(string className, string message, [CallerMemberName] st
206156
LogInternal(LogLevel.Debug, className, message, methodName);
207157
}
208158

209-
/// Example: "|ClassName.MethodName|Message""
210-
public static void Debug(string message)
211-
{
212-
LogInternal(message, LogLevel.Debug);
213-
}
214-
215159
public static void Info(string className, string message, [CallerMemberName] string methodName = "")
216160
{
217161
LogInternal(LogLevel.Info, className, message, methodName);
218162
}
219163

220-
/// Example: "|ClassName.MethodName|Message"
221-
public static void Info(string message)
222-
{
223-
LogInternal(message, LogLevel.Info);
224-
}
225-
226164
public static void Warn(string className, string message, [CallerMemberName] string methodName = "")
227165
{
228166
LogInternal(LogLevel.Warn, className, message, methodName);

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ void continueAction(Task t)
222222
#if DEBUG
223223
throw t.Exception;
224224
#else
225-
Log.Error($"Error happen in task dealing with viewupdate for results. {t.Exception}");
225+
App.API.LogError(ClassName, $"Error happen in task dealing with viewupdate for results. {t.Exception}");
226226
_resultsViewUpdateTask =
227227
Task.Run(UpdateActionAsync).ContinueWith(continueAction, CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted, TaskScheduler.Default);
228228
#endif
@@ -892,7 +892,7 @@ public bool InternalPreviewVisible
892892
#if DEBUG
893893
throw new NotImplementedException("ResultAreaColumn should match ResultAreaColumnPreviewShown/ResultAreaColumnPreviewHidden value");
894894
#else
895-
Log.Error("MainViewModel", "ResultAreaColumnPreviewHidden/ResultAreaColumnPreviewShown int value not implemented", "InternalPreviewVisible");
895+
App.API.LogError(ClassName, "ResultAreaColumnPreviewHidden/ResultAreaColumnPreviewShown int value not implemented", "InternalPreviewVisible");
896896
return false;
897897
#endif
898898
}

0 commit comments

Comments
 (0)