diff --git a/src/TUI/Logs/Log.cs b/src/TUI/Logs/Log.cs index 2b416d0..f497ffb 100644 --- a/src/TUI/Logs/Log.cs +++ b/src/TUI/Logs/Log.cs @@ -1,14 +1,54 @@ namespace TUI.Logs; +enum Level +{ + Trace = 60, + Debug = 50, + Info = 40, + Warning = 30, + Error = 20, + Fatal = 10, +} + public static class Log { + private static readonly int LogLevel = (int)Level.Info; private static string Now => DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - public static void Trace(string message) => Write("🌚", message); - public static void Debug(string message) => Write("🦎", message); - public static void Info(string message) => Write("🦋", message); - public static void Warning(string message) => Write("🍋", message); - public static void Error(string message) => Write("🐞", message); - public static void Fatal(string message) => Write("💀", message); + public static void Trace(string message) + { + if (LogLevel < 60) return; + Write("🌚", message); + } + + public static void Debug(string message) + { + if (LogLevel < 50) return; + Write("🦎", message); + } + + public static void Info(string message) + { + if (LogLevel < 40) return; + Write("🦋", message); + } + + public static void Warning(string message) + { + if (LogLevel < 30) return; + Write("🍋", message); + } + + public static void Error(string message) + { + if (LogLevel < 20) return; + Write("🐞", message); + } + + public static void Fatal(string message) + { + if (LogLevel < 10) return; + Write("💀", message); + } public static void Write(string icon, string message) { diff --git a/src/TUI/Providers/Dependencies/DependencyRepository.cs b/src/TUI/Providers/Dependencies/DependencyRepository.cs index 56f54c6..9503297 100644 --- a/src/TUI/Providers/Dependencies/DependencyRepository.cs +++ b/src/TUI/Providers/Dependencies/DependencyRepository.cs @@ -69,6 +69,7 @@ public class DependencyRepository if (project.Hub.Type == "gitlab") { var endpoint = GetGitlabEndpoint(project.Hub.Origin, project.Id); + Log.Trace($"Fetch endpoint {endpoint}."); using HttpClient client = new(); var json = client.GetStringAsync(endpoint).GetAwaiter().GetResult(); var packageJson = JsonSerializer.Deserialize(json); diff --git a/src/TUI/Store/DependenciesStore.cs b/src/TUI/Store/DependenciesStore.cs index 7441dbd..86ecbb1 100644 --- a/src/TUI/Store/DependenciesStore.cs +++ b/src/TUI/Store/DependenciesStore.cs @@ -25,11 +25,21 @@ public class DependenciesStore { return Repository.ReadActual(project); } - catch(Exception ex) + catch (Exception ex) { - Log.Error("Fail load actual deps for project " +project.Name + ". " + ex.Message); - Debugger.Log(0, "error", ex.Message); - SpeakerComponent.Instance.Shout(Symbols.Error.Error(), $"Fetch failed for project{project.Name}"); + if (ex.Message.Contains("404 (Not Found)")) + { + Log.Warning("Fail load actual deps for project " + project.Name + "."); + Debugger.Log(0, "error", ex.Message); + SpeakerComponent.Instance.Shout(Symbols.Error.Warning(), $"Project {project.Name} not found."); + } + else + { + Log.Error("Fetch failed for project " + project.Name + ". " + ex.Message); + Debugger.Log(0, "warning", ex.Message); + SpeakerComponent.Instance.Shout(Symbols.Error.Error(), $"Fetch failed for project{project.Name}"); + } + return new List(); } }