move log to temp path
This commit is contained in:
Executable
+34
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Shadowsocks.Controller
|
||||
{
|
||||
public class Logging
|
||||
{
|
||||
public static string LogFile;
|
||||
|
||||
public static bool OpenLogFile()
|
||||
{
|
||||
try
|
||||
{
|
||||
string temppath = Path.GetTempPath();
|
||||
LogFile = Path.Combine(temppath, "shadowsocks.log");
|
||||
FileStream fs = new FileStream(LogFile, FileMode.Append);
|
||||
TextWriter tmp = Console.Out;
|
||||
StreamWriter sw = new StreamWriter(fs);
|
||||
sw.AutoFlush = true;
|
||||
Console.SetOut(sw);
|
||||
Console.SetError(sw);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,19 +47,7 @@ namespace Shadowsocks
|
||||
}
|
||||
LoadLibrary(dllPath);
|
||||
|
||||
try
|
||||
{
|
||||
FileStream fs = new FileStream("shadowsocks.log", FileMode.Append);
|
||||
TextWriter tmp = Console.Out;
|
||||
StreamWriter sw = new StreamWriter(fs);
|
||||
sw.AutoFlush = true;
|
||||
Console.SetOut(sw);
|
||||
Console.SetError(sw);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
}
|
||||
Logging.OpenLogFile();
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
ShadowsocksController controller = new ShadowsocksController();
|
||||
|
||||
+12
-3
@@ -64,6 +64,7 @@
|
||||
this.AddButton = new System.Windows.Forms.Button();
|
||||
this.ServerGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.ServersListBox = new System.Windows.Forms.ListBox();
|
||||
this.ShowLogItem = new System.Windows.Forms.MenuItem();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
this.panel1.SuspendLayout();
|
||||
this.panel3.SuspendLayout();
|
||||
@@ -289,6 +290,7 @@
|
||||
this.menuItem4,
|
||||
this.editPACFileItem,
|
||||
this.QRCodeItem,
|
||||
this.ShowLogItem,
|
||||
this.aboutItem,
|
||||
this.menuItem3,
|
||||
this.quitItem});
|
||||
@@ -337,18 +339,18 @@
|
||||
//
|
||||
// aboutItem
|
||||
//
|
||||
this.aboutItem.Index = 5;
|
||||
this.aboutItem.Index = 6;
|
||||
this.aboutItem.Text = "About...";
|
||||
this.aboutItem.Click += new System.EventHandler(this.AboutItem_Click);
|
||||
//
|
||||
// menuItem3
|
||||
//
|
||||
this.menuItem3.Index = 6;
|
||||
this.menuItem3.Index = 7;
|
||||
this.menuItem3.Text = "-";
|
||||
//
|
||||
// quitItem
|
||||
//
|
||||
this.quitItem.Index = 7;
|
||||
this.quitItem.Index = 8;
|
||||
this.quitItem.Text = "&Quit";
|
||||
this.quitItem.Click += new System.EventHandler(this.Quit_Click);
|
||||
//
|
||||
@@ -402,6 +404,12 @@
|
||||
this.ServersListBox.TabIndex = 5;
|
||||
this.ServersListBox.SelectedIndexChanged += new System.EventHandler(this.ServersListBox_SelectedIndexChanged);
|
||||
//
|
||||
// ShowLogItem
|
||||
//
|
||||
this.ShowLogItem.Index = 5;
|
||||
this.ShowLogItem.Text = "Show Logs...";
|
||||
this.ShowLogItem.Click += new System.EventHandler(this.ShowLogItem_Click);
|
||||
//
|
||||
// ConfigForm
|
||||
//
|
||||
this.AcceptButton = this.OKButton;
|
||||
@@ -471,6 +479,7 @@
|
||||
private System.Windows.Forms.TextBox RemarksTextBox;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.MenuItem QRCodeItem;
|
||||
private System.Windows.Forms.MenuItem ShowLogItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -298,6 +298,13 @@ namespace Shadowsocks.View
|
||||
controller.SaveConfig(configuration);
|
||||
}
|
||||
|
||||
private void ShowLogItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
string argument = Logging.LogFile;
|
||||
|
||||
System.Diagnostics.Process.Start("notepad.exe", argument);
|
||||
}
|
||||
|
||||
private void ConfigForm_Shown(object sender, EventArgs e)
|
||||
{
|
||||
IPTextBox.Focus();
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
<Compile Include="3rd\QRCodeCS.cs" />
|
||||
<Compile Include="3rd\SimpleJson.cs" />
|
||||
<Compile Include="Controller\FileManager.cs" />
|
||||
<Compile Include="Controller\Logging.cs" />
|
||||
<Compile Include="Encrypt\EncryptorBase.cs" />
|
||||
<Compile Include="Encrypt\EncryptorFactory.cs" />
|
||||
<Compile Include="Encrypt\PolarSSL.cs" />
|
||||
|
||||
Reference in New Issue
Block a user