mirror of
https://github.com/openziti/desktop-edge-win.git
synced 2026-10-13 00:02:50 +00:00
ensure UI can get the current log level of the service so the user can be shown what it's at currently
add/refine debug output
This commit is contained in:
@@ -4,21 +4,11 @@ using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.IO;
|
||||
using ZitiDesktopEdge.Models;
|
||||
using System.IO.Compression;
|
||||
|
||||
using ZitiDesktopEdge.ServiceClient;
|
||||
using System.ServiceProcess;
|
||||
using System.Linq;
|
||||
using System.Runtime.Remoting.Messaging;
|
||||
using System.Diagnostics;
|
||||
using System.Security.Principal;
|
||||
using System.Net;
|
||||
using System.Windows.Controls;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Interop;
|
||||
|
||||
namespace ZitiDesktopEdge {
|
||||
|
||||
@@ -250,6 +240,7 @@ namespace ZitiDesktopEdge {
|
||||
private void ServiceClient_OnTunnelStatusEvent(object sender, TunnelStatusEvent e) {
|
||||
if (e == null) return; //just skip it for now...
|
||||
Debug.WriteLine($"==== TunnelStatusEvent: ");
|
||||
e.Status.Dump(Console.Out);
|
||||
this.Dispatcher.Invoke(() => {
|
||||
if(e.ApiVersion != Client.EXPECTED_API_VERSION) {
|
||||
SetCantDisplay("Version mismatch!", "The version of the Service is not compatible");
|
||||
@@ -543,5 +534,22 @@ namespace ZitiDesktopEdge {
|
||||
private void Label_MouseDoubleClick(object sender, MouseButtonEventArgs e) {
|
||||
Placement();
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
serviceClient.SetLogLevel(NextLevel());
|
||||
}
|
||||
|
||||
int cur = 0;
|
||||
LogLevelEnum[] levels = new LogLevelEnum[] { LogLevelEnum.FATAL, LogLevelEnum.ERROR, LogLevelEnum.WARN, LogLevelEnum.INFO, LogLevelEnum.DEBUG, LogLevelEnum.TRACE, LogLevelEnum.VERBOSE };
|
||||
public LogLevelEnum NextLevel()
|
||||
{
|
||||
cur++;
|
||||
if (cur > 6)
|
||||
{
|
||||
cur = 0;
|
||||
}
|
||||
return levels[cur];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,15 +180,19 @@ namespace ZitiDesktopEdge.ServiceClient
|
||||
|
||||
public IpInfo IpInfo { get; set; }
|
||||
|
||||
public string LogLevel { get; set; }
|
||||
|
||||
public void Dump(System.IO.TextWriter writer)
|
||||
{
|
||||
writer.WriteLine($"Tunnel Active: {Active}");
|
||||
writer.WriteLine($" LogLevel : {LogLevel}");
|
||||
writer.WriteLine($" EvaluatedLogLevel: {EvaluateLogLevel()}");
|
||||
foreach (Identity id in Identities)
|
||||
{
|
||||
writer.WriteLine($" FingerPrint: {id.FingerPrint}");
|
||||
writer.WriteLine($" Name: {id.Name}");
|
||||
writer.WriteLine($" Active: {id.Active}");
|
||||
writer.WriteLine($" Status: {id.Status}");
|
||||
writer.WriteLine($" Name : {id.Name}");
|
||||
writer.WriteLine($" Active : {id.Active}");
|
||||
writer.WriteLine($" Status : {id.Status}");
|
||||
writer.WriteLine($" Services:");
|
||||
foreach (Service s in id.Services)
|
||||
{
|
||||
@@ -197,6 +201,20 @@ namespace ZitiDesktopEdge.ServiceClient
|
||||
writer.WriteLine("=============================================");
|
||||
}
|
||||
}
|
||||
|
||||
public LogLevelEnum EvaluateLogLevel()
|
||||
{
|
||||
try
|
||||
{
|
||||
LogLevelEnum l = (LogLevelEnum) Enum.Parse(typeof(LogLevelEnum), LogLevel.ToUpper());
|
||||
return l;
|
||||
}
|
||||
catch
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Could not parse response LogLevel from sevice - guessing INFO? " + LogLevel);
|
||||
return LogLevelEnum.INFO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ServiceException : System.Exception
|
||||
|
||||
Reference in New Issue
Block a user