mirror of
https://github.com/dnwSilver/tld.git
synced 2025-01-19 09:22:08 +00:00
🔊 Add log levels.
This commit is contained in:
parent
220c33ed97
commit
5eda85d006
@ -1,14 +1,54 @@
|
|||||||
namespace TUI.Logs;
|
namespace TUI.Logs;
|
||||||
|
|
||||||
|
enum Level
|
||||||
|
{
|
||||||
|
Trace = 60,
|
||||||
|
Debug = 50,
|
||||||
|
Info = 40,
|
||||||
|
Warning = 30,
|
||||||
|
Error = 20,
|
||||||
|
Fatal = 10,
|
||||||
|
}
|
||||||
|
|
||||||
public static class Log
|
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");
|
private static string Now => DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||||
public static void Trace(string message) => Write("🌚", message);
|
public static void Trace(string message)
|
||||||
public static void Debug(string message) => Write("🦎", message);
|
{
|
||||||
public static void Info(string message) => Write("🦋", message);
|
if (LogLevel < 60) return;
|
||||||
public static void Warning(string message) => Write("🍋", message);
|
Write("🌚", message);
|
||||||
public static void Error(string message) => Write("🐞", message);
|
}
|
||||||
public static void Fatal(string message) => 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)
|
public static void Write(string icon, string message)
|
||||||
{
|
{
|
||||||
|
@ -69,6 +69,7 @@ public class DependencyRepository
|
|||||||
if (project.Hub.Type == "gitlab")
|
if (project.Hub.Type == "gitlab")
|
||||||
{
|
{
|
||||||
var endpoint = GetGitlabEndpoint(project.Hub.Origin, project.Id);
|
var endpoint = GetGitlabEndpoint(project.Hub.Origin, project.Id);
|
||||||
|
Log.Trace($"Fetch endpoint {endpoint}.");
|
||||||
using HttpClient client = new();
|
using HttpClient client = new();
|
||||||
var json = client.GetStringAsync(endpoint).GetAwaiter().GetResult();
|
var json = client.GetStringAsync(endpoint).GetAwaiter().GetResult();
|
||||||
var packageJson = JsonSerializer.Deserialize<PackageJson>(json);
|
var packageJson = JsonSerializer.Deserialize<PackageJson>(json);
|
||||||
|
@ -25,11 +25,21 @@ public class DependenciesStore
|
|||||||
{
|
{
|
||||||
return Repository.ReadActual(project);
|
return Repository.ReadActual(project);
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Error("Fail load actual deps for project " +project.Name + ". " + ex.Message);
|
if (ex.Message.Contains("404 (Not Found)"))
|
||||||
Debugger.Log(0, "error", ex.Message);
|
{
|
||||||
SpeakerComponent.Instance.Shout(Symbols.Error.Error(), $"Fetch failed for project{project.Name}");
|
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<Dependency>();
|
return new List<Dependency>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user