Skip to content

Commit

Permalink
enable logging and open logs from options
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTheGr8 committed Sep 13, 2013
1 parent 0836154 commit 44df05d
Show file tree
Hide file tree
Showing 9 changed files with 652 additions and 664 deletions.
14 changes: 7 additions & 7 deletions FTPboxLib/FTPboxLib/Console/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class Log

private static string _fname;
private static l _level;
private static bool _debug;
public static bool DebugEnabled;

private const string FontFormat = "<font color=\"{0}\">{1}</font>";
private const string OutputFormat = "[ {0} - {1} ] : {2} <br />"; // timestamp, caller, log message
Expand All @@ -49,9 +49,9 @@ public static void Init(string fname, l level, bool del, bool debug)
{
_fname = fname;
_level = level;
_debug = debug;
DebugEnabled = debug;

if (del)
if (del && File.Exists(fname))
{
try
{
Expand All @@ -65,8 +65,8 @@ public static void Init(string fname, l level, bool del, bool debug)
Log.Write(l.Warning, "Could not delete previous log file");
}
}

Thread wrtThread = new Thread(new ThreadStart(LogWriter));
Thread wrtThread = new Thread(LogWriter);
wrtThread.Start();
}

Expand Down Expand Up @@ -125,7 +125,7 @@ private static void outputLog(int iIndex)
DateTime thisDate = DateTime.Now;
CultureInfo culture = new CultureInfo("en-US");

if (_debug)
if (DebugEnabled)
finalWrite(formatOutLine(lItem));

if ((_level & lItem.Level) != lItem.Level)
Expand Down Expand Up @@ -204,7 +204,7 @@ private static string getColorCode(l li)
// if l.Client
return "green";

}
}

private class LogItem
{
Expand Down
5 changes: 5 additions & 0 deletions FTPboxLib/FTPboxLib/Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public static string AppdataFolder
}
}

public static string DebugLogPath
{
get { return Path.Combine(AppdataFolder, "Debug.html"); }
}

public static string WebInterfaceLink
{
get
Expand Down
2 changes: 2 additions & 0 deletions FTPboxLib/FTPboxLib/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ public class SettingsGeneral
public int UploadLimit = 0;

public int DefaultProfile = 0;

public bool EnableLogging = true;
}

public class SettingsProfile
Expand Down
Binary file modified Windows/FTPbox.suo
Binary file not shown.
Binary file modified Windows/FTPbox/FTPboxLib.dll
Binary file not shown.
80 changes: 27 additions & 53 deletions Windows/FTPbox/Forms/fMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 23 additions & 15 deletions Windows/FTPbox/Forms/fMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ private void fMain_Load(object sender, EventArgs e)
Common.LoadLocalFolders();
Load_Recent();

if (!Log.DebugEnabled && Settings.settingsGeneral.EnableLogging)
Log.DebugEnabled = true;

Notifications.NotificationReady += (o, n) =>
{
link = Common.LinkToRecent();
Expand Down Expand Up @@ -237,6 +240,7 @@ public void UpdateDetails()
tParent.Text = Profile.HttpPath;

chkShowNots.Checked = Settings.settingsGeneral.Notifications;
chkEnableLogging.Checked = Settings.settingsGeneral.EnableLogging;

if (Profile.TrayAction == TrayAction.OpenInBrowser)
rOpenInBrowser.Checked = true;
Expand Down Expand Up @@ -445,7 +449,8 @@ private void Set_Language(string lan)
chkWebInt.Text = Common.Languages.Get(lan + "/web_interface/use_webint", "Use the Web Interface");
labViewInBrowser.Text = Common.Languages.Get(lan + "/web_interface/view", "(View in browser)");
chkShowNots.Text = Common.Languages.Get(lan + "/main_form/show_nots", "Show notifications");
chkStartUp.Text = Common.Languages.Get(lan + "/main_form/start_on_startup", "Start on system start-up");
chkStartUp.Text = Common.Languages.Get(lan + "/main_form/start_on_startup", "Start on system start-up");
chkEnableLogging.Text = Common.Languages.Get(lan + "/main_form/view_log", "View Log");
//account tab
lProfile.Text = Common.Languages.Get(lan + "/main_form/profile", "Profile") + ":";
gDetails.Text = Common.Languages.Get(lan + "/main_form/details", "Details");
Expand Down Expand Up @@ -536,20 +541,6 @@ private void Set_Language(string lan)
Settings.SaveGeneral();
}

private void cmbLang_SelectedIndexChanged(object sender, EventArgs e)
{
string lan = cmbLang.Text.Substring(cmbLang.Text.IndexOf("(") + 1);
lan = lan.Substring(0, lan.Length - 1);
try
{
Set_Language(lan);
}
catch (Exception ex)
{
Common.LogError(ex);
}
}

/// <summary>
/// When the user changes to another language, translate every label etc to that language.
/// </summary>
Expand Down Expand Up @@ -1310,6 +1301,23 @@ private void labViewInBrowser_LinkClicked(object sender, LinkLabelLinkClickedEve
Process.Start(Profile.WebInterfaceLink);
}

private void chkEnableLogging_CheckedChanged(object sender, EventArgs e)
{
Settings.settingsGeneral.EnableLogging = chkEnableLogging.Checked;
Settings.SaveGeneral();

Log.DebugEnabled = chkEnableLogging.Checked || Profile.IsDebugMode;
}

private void bBrowseLogs_Click(object sender, EventArgs e)
{
string logFile = Path.Combine(Profile.AppdataFolder, "Debug.html");

if (File.Exists(logFile))
Process.Start("explorer.exe", logFile);

}

#endregion

#region Account Tab - Event Handlers
Expand Down
Loading

0 comments on commit 44df05d

Please sign in to comment.