diff --git a/shadowsocks-csharp/Controller/Logging.cs b/shadowsocks-csharp/Controller/Logging.cs
new file mode 100755
index 00000000..58a994f5
--- /dev/null
+++ b/shadowsocks-csharp/Controller/Logging.cs
@@ -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;
+ }
+ }
+ }
+}
diff --git a/shadowsocks-csharp/Program.cs b/shadowsocks-csharp/Program.cs
index 516bdf80..a42a97ae 100755
--- a/shadowsocks-csharp/Program.cs
+++ b/shadowsocks-csharp/Program.cs
@@ -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();
diff --git a/shadowsocks-csharp/View/ConfigForm.Designer.cs b/shadowsocks-csharp/View/ConfigForm.Designer.cs
index b2d20a84..7fb5c9a5 100755
--- a/shadowsocks-csharp/View/ConfigForm.Designer.cs
+++ b/shadowsocks-csharp/View/ConfigForm.Designer.cs
@@ -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;
}
}
diff --git a/shadowsocks-csharp/View/ConfigForm.cs b/shadowsocks-csharp/View/ConfigForm.cs
index 51079ed9..9ba3d032 100755
--- a/shadowsocks-csharp/View/ConfigForm.cs
+++ b/shadowsocks-csharp/View/ConfigForm.cs
@@ -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();
diff --git a/shadowsocks-csharp/shadowsocks-csharp.csproj b/shadowsocks-csharp/shadowsocks-csharp.csproj
index c1c08d22..ab31982a 100755
--- a/shadowsocks-csharp/shadowsocks-csharp.csproj
+++ b/shadowsocks-csharp/shadowsocks-csharp.csproj
@@ -68,6 +68,7 @@
+