mirror of
https://github.com/openziti/desktop-edge-win.git
synced 2026-10-13 08:11:16 +00:00
Merge pull request #255 from openziti/issue-254-unify-log-location
Issue 254 unify log location
This commit is contained in:
@@ -41,8 +41,11 @@ namespace ZitiDesktopEdge
|
||||
private string _updateUrl = "https://api.github.com/repos/openziti/desktop-edge-win/releases/latest";
|
||||
private string _downloadUrl = "";
|
||||
|
||||
private string appVersion = null;
|
||||
public MainMenu() {
|
||||
InitializeComponent();
|
||||
|
||||
appVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
LicensesItems.Text = licenseData;
|
||||
CheckUpdates();
|
||||
}
|
||||
@@ -107,10 +110,9 @@ namespace ZitiDesktopEdge
|
||||
StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream());
|
||||
string result = streamReader.ReadToEnd();
|
||||
JObject json = JObject.Parse(result);
|
||||
string currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
string serverVersion = json.Property("tag_name").Value.ToString() + ".0";
|
||||
|
||||
Version installed = new Version(currentVersion);
|
||||
Version installed = new Version(appVersion);
|
||||
Version published = new Version(serverVersion);
|
||||
int compare = installed.CompareTo(published);
|
||||
if (compare < 0)
|
||||
@@ -164,7 +166,7 @@ namespace ZitiDesktopEdge
|
||||
}
|
||||
|
||||
// Interface Version
|
||||
VersionInfo.Content = "App: " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()+" Service: "+ version;
|
||||
VersionInfo.Content = $"App: {appVersion} Service: {version}";
|
||||
|
||||
} else if (menuState=="Advanced") {
|
||||
MenuTitle.Content = "Advanced Settings";
|
||||
@@ -226,11 +228,14 @@ namespace ZitiDesktopEdge
|
||||
|
||||
async private void ShowFeedback(object sender, MouseButtonEventArgs e) {
|
||||
DataClient client = (DataClient)Application.Current.Properties["ServiceClient"];
|
||||
var mailMessage = new MailMessage();
|
||||
mailMessage.From = new MailAddress("ziti-support@netfoundry.io");
|
||||
var mailMessage = new MailMessage("ziti-support@netfoundry.io", "ziti-support@netfoundry.io");
|
||||
mailMessage.Subject = "Ziti Support";
|
||||
mailMessage.IsBodyHtml = true;
|
||||
mailMessage.Body = "";
|
||||
mailMessage.IsBodyHtml = false;
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
||||
sb.Append("Logs collected at : " + DateTime.Now.ToString());
|
||||
sb.Append(". client version : " + appVersion);
|
||||
|
||||
mailMessage.Body = sb.ToString();
|
||||
|
||||
string timestamp = DateTime.Now.ToFileTime().ToString();
|
||||
var monitorClient = (MonitorClient)Application.Current.Properties["MonitorClient"];
|
||||
@@ -255,15 +260,14 @@ namespace ZitiDesktopEdge
|
||||
}
|
||||
|
||||
var p = Process.Start(emlFile);
|
||||
Task.Run(async () => {
|
||||
logger.Info("Waiting to send email...");
|
||||
p.WaitForExit();
|
||||
logger.Info("Email sent or cancelled... removing file: {0}", emlFile);
|
||||
p.Exited += (object lambdaSender, EventArgs lambdaEventArgs) => {
|
||||
logger.Info("Removing temp file: {0}", emlFile);
|
||||
File.Delete(emlFile);
|
||||
logger.Info("file removed: {0}", emlFile);
|
||||
});
|
||||
};
|
||||
p.EnableRaisingEvents = true;
|
||||
}
|
||||
private void ShowSupport(object sender, MouseButtonEventArgs e) {
|
||||
|
||||
private void ShowSupport(object sender, MouseButtonEventArgs e) {
|
||||
Process.Start(new ProcessStartInfo("https://openziti.discourse.group/") { UseShellExecute = true });
|
||||
}
|
||||
|
||||
|
||||
@@ -66,8 +66,10 @@ namespace ZitiDesktopEdge {
|
||||
var curdir = Path.GetDirectoryName(asm.Location);
|
||||
string nlogFile = Path.Combine(curdir, logname + "-log.config");
|
||||
|
||||
bool byFile = false;
|
||||
if (File.Exists(nlogFile)) {
|
||||
LogManager.Configuration = new XmlLoggingConfiguration(nlogFile);
|
||||
byFile = true;
|
||||
} else {
|
||||
var config = new LoggingConfiguration();
|
||||
// Targets where to log to: File and Console
|
||||
@@ -87,7 +89,8 @@ namespace ZitiDesktopEdge {
|
||||
// Apply config
|
||||
LogManager.Configuration = config;
|
||||
}
|
||||
logger.Info("service started - logger initialized");
|
||||
logger.Info("============================== UI started ==============================");
|
||||
logger.Info("logger initialized using file? {0}", byFile);
|
||||
|
||||
App.Current.MainWindow.WindowState = WindowState.Normal;
|
||||
App.Current.MainWindow.Closing += MainWindow_Closing;
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
function EndLogs {
|
||||
echo "===================================== collecting logs ends ====================================="
|
||||
echo ""
|
||||
}
|
||||
function ExitWithCode($exitcode) {
|
||||
#$host.SetShouldExit($exitcode)
|
||||
exit $exitcode
|
||||
}
|
||||
|
||||
$now=(Get-Date).ToString('yyyy-MM-dd_HHmmss')
|
||||
$logroot="${env:ProgramFiles(x86)}\NetFoundry, Inc\Ziti Desktop Edge\logs"
|
||||
$ipinfo="${logroot}\ipconfig.info.txt"
|
||||
|
||||
$logdest="$logroot\ziti-service\"
|
||||
$logdest
|
||||
$logsrc="${env:WINDIR}\System32\config\systemprofile\AppData\Roaming\NetFoundry\*.log"
|
||||
$destArchive="${logroot}\logs-${now}.zip"
|
||||
|
||||
echo ""
|
||||
echo "===================================== collecting logs begins ====================================="
|
||||
echo " checking for admin privs"
|
||||
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
|
||||
$isAdmin=$currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||
if (!$isAdmin) {
|
||||
echo ""
|
||||
echo " ERROR: administrator rights not found"
|
||||
echo " this script requires access to files on the administrator can access"
|
||||
echo ""
|
||||
EndLogs
|
||||
exit 11
|
||||
}
|
||||
echo " ensure folder exists: $logdest"
|
||||
mkdir $logdest -ErrorAction SilentlyContinue > $null
|
||||
|
||||
echo " issuing ipconfig /all"
|
||||
echo " "
|
||||
ipconfig /all > "$ipinfo"
|
||||
|
||||
echo " copying log files...."
|
||||
echo " source: $logsrc"
|
||||
echo " to: $logdest"
|
||||
cp $logsrc $logdest
|
||||
|
||||
echo " "
|
||||
echo " creating archive: ${destArchive}"
|
||||
mkdir "${logroot}\UI" -ErrorAction SilentlyContinue > $null
|
||||
compress-archive -Path "${ipinfo}","${logroot}\ziti-service","${logroot}\UI","${logroot}\ZitiMonitorService" -DestinationPath "${destArchive}"
|
||||
|
||||
echo " "
|
||||
echo " removing log folder: $logdest"
|
||||
rm -r "$logdest"
|
||||
echo " removing ipinfo : $ipinfo"
|
||||
rm "$ipinfo"
|
||||
|
||||
$Acl = Get-ACL $logroot
|
||||
$AccessRule= New-Object System.Security.AccessControl.FileSystemAccessRule("everyone","FullControl","ContainerInherit,Objectinherit","none","Allow")
|
||||
$Acl.AddAccessRule($AccessRule)
|
||||
Set-Acl $logroot $Acl
|
||||
|
||||
echo " "
|
||||
echo " Logs collected successfully"
|
||||
echo " Log location: ${destArchive}"
|
||||
|
||||
EndLogs
|
||||
@@ -21,8 +21,10 @@ namespace ZitiUpdateService {
|
||||
var curdir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
string nlogFile = Path.Combine(curdir, $"{logname}-log.config");
|
||||
|
||||
bool byFile = false;
|
||||
if (File.Exists(nlogFile)) {
|
||||
LogManager.Configuration = new XmlLoggingConfiguration(nlogFile);
|
||||
byFile = true;
|
||||
} else {
|
||||
var config = new LoggingConfiguration();
|
||||
// Targets where to log to: File and Console
|
||||
@@ -42,7 +44,8 @@ namespace ZitiUpdateService {
|
||||
// Apply config
|
||||
LogManager.Configuration = config;
|
||||
}
|
||||
Logger.Info("service started - logger initialized");
|
||||
Logger.Info("============================== ziti-monitor started ==============================");
|
||||
Logger.Info("logger initialized using file? {0}", byFile);
|
||||
|
||||
UpdateService updateSvc = new UpdateService();
|
||||
updateSvc.AutoLog = true;
|
||||
|
||||
@@ -18,9 +18,19 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func ExecutablePath() string {
|
||||
fi, err := os.Executable()
|
||||
if err != nil {
|
||||
log.Panic("COULD NOT STAT os.executable! %v", err)
|
||||
}
|
||||
dir := filepath.Dir(fi)
|
||||
return dir
|
||||
}
|
||||
func File() string {
|
||||
return Path() + "config.json"
|
||||
}
|
||||
@@ -29,9 +39,11 @@ func Path() string {
|
||||
return path + string(os.PathSeparator) + "NetFoundry" + string(os.PathSeparator)
|
||||
}
|
||||
func LogFile() string {
|
||||
return Path() + "ziti-tunneler.log"
|
||||
return filepath.Join(LogsPath(), "ziti-tunneler.log")
|
||||
}
|
||||
func LogsPath() string {
|
||||
return filepath.Join(ExecutablePath(), "logs", "service")
|
||||
}
|
||||
|
||||
func BackupFile() string {
|
||||
return File() + ".backup"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user