Browse Source

move log to temp path

tags/3.2
clowwindy 10 years ago
parent
commit
492869fd5c
5 changed files with 55 additions and 16 deletions
  1. +34
    -0
      shadowsocks-csharp/Controller/Logging.cs
  2. +1
    -13
      shadowsocks-csharp/Program.cs
  3. +12
    -3
      shadowsocks-csharp/View/ConfigForm.Designer.cs
  4. +7
    -0
      shadowsocks-csharp/View/ConfigForm.cs
  5. +1
    -0
      shadowsocks-csharp/shadowsocks-csharp.csproj

+ 34
- 0
shadowsocks-csharp/Controller/Logging.cs View File

@@ -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;
}
}
}
}

+ 1
- 13
shadowsocks-csharp/Program.cs View File

@@ -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
shadowsocks-csharp/View/ConfigForm.Designer.cs View File

@@ -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;
}
}

+ 7
- 0
shadowsocks-csharp/View/ConfigForm.cs View File

@@ -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();


+ 1
- 0
shadowsocks-csharp/shadowsocks-csharp.csproj View File

@@ -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" />


Loading…
Cancel
Save