Skip to content

Commit

Permalink
refactored logging
Browse files Browse the repository at this point in the history
added digest to ptz commands
updated connection factory
  • Loading branch information
ispysoftware committed Nov 27, 2015
1 parent 494a1cf commit 33c2879
Show file tree
Hide file tree
Showing 74 changed files with 685 additions and 629 deletions.
5 changes: 3 additions & 2 deletions AddCamera.cs
Expand Up @@ -16,6 +16,7 @@
using iSpyApplication.Sources;
using iSpyApplication.Sources.Audio;
using iSpyApplication.Sources.Video;
using iSpyApplication.Utilities;
using iSpyPRO.DirectShow.Internals;


Expand Down Expand Up @@ -917,7 +918,7 @@ private void CameraNewFrame(object sender, NewFrameEventArgs e)
}
catch(Exception ex)
{
MainForm.LogExceptionToFile(ex);
Logger.LogExceptionToFile(ex);
}
}

Expand Down Expand Up @@ -1805,7 +1806,7 @@ private void SendPtzCommand(string cmd, bool wait)
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex);
Logger.LogExceptionToFile(ex);
MessageBox.Show(ex.Message, LocRm.GetString("Error"));
}
}
Expand Down
3 changes: 2 additions & 1 deletion AddFloorPlan.cs
Expand Up @@ -5,6 +5,7 @@
using AForge.Imaging.Filters;
using System.Linq;
using iSpyApplication.Controls;
using iSpyApplication.Utilities;

namespace iSpyApplication
{
Expand Down Expand Up @@ -39,7 +40,7 @@ private void AddFloorPlanLoad(object sender, EventArgs e)
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex);
Logger.LogExceptionToFile(ex);
}
}

Expand Down
3 changes: 2 additions & 1 deletion CheckPassword.cs
@@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.Windows.Forms;
using iSpyApplication.Utilities;

namespace iSpyApplication
{
Expand All @@ -21,7 +22,7 @@ private void DoCheckPassword()
MainForm.NeedsResourceUpdate = true;
MainForm.Group = g.name;
DialogResult = DialogResult.OK;
MainForm.LogMessageToFile("Login: "+g.name);
Logger.LogMessageToFile("Login: "+g.name);
Close();
return;
}
Expand Down
19 changes: 10 additions & 9 deletions Cloud/Drive.cs
Expand Up @@ -11,6 +11,7 @@
using Google.Apis.Services;
using Google.Apis.Upload;
using Google.Apis.Util.Store;
using iSpyApplication.Utilities;
using File = Google.Apis.Drive.v2.Data.File;

namespace iSpyApplication.Cloud
Expand Down Expand Up @@ -115,7 +116,7 @@ public static bool Authorise()
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex);
Logger.LogExceptionToFile(ex);
return false;
}

Expand All @@ -140,7 +141,7 @@ private static string GetOrCreateFolder(string path)
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex);
Logger.LogExceptionToFile(ex);
return "";
}
bool first = true;
Expand Down Expand Up @@ -253,7 +254,7 @@ private static void Upload(object state)
catch(Exception ex)
{
//file doesn't exist
MainForm.LogExceptionToFile(ex);
Logger.LogExceptionToFile(ex);
return;
}
var mt = MimeTypes.GetMimeType(fi.Extension);
Expand All @@ -275,13 +276,13 @@ private static void Upload(object state)
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex);
Logger.LogExceptionToFile(ex);
}
}
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex);
Logger.LogExceptionToFile(ex);
}
Upload(null);
}
Expand All @@ -294,7 +295,7 @@ private static void Upload(object state)
static void RequestResponseReceived(File obj)
{
string msg = "File uploaded to google drive: <a href=\"" + obj.DownloadUrl + "\">" +obj.Title + "</a>";
MainForm.LogMessageToFile(msg);
Logger.LogMessageToFile(msg);
}

private static void RequestProgressChanged(IUploadProgress obj)
Expand All @@ -303,17 +304,17 @@ private static void RequestProgressChanged(IUploadProgress obj)
{
case UploadStatus.Failed:
if (obj.Exception!=null)
MainForm.LogErrorToFile("Upload to Google Drive failed ("+obj.Exception.Message+")");
Logger.LogErrorToFile("Upload to Google Drive failed ("+obj.Exception.Message+")");
else
{
MainForm.LogErrorToFile("Upload to Google Drive failed");
Logger.LogErrorToFile("Upload to Google Drive failed");
}
break;
}

if (obj.Exception != null)
{
MainForm.LogExceptionToFile(obj.Exception);
Logger.LogExceptionToFile(obj.Exception);
}


Expand Down
11 changes: 6 additions & 5 deletions Cloud/Dropbox.cs
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Threading;
using DropNet;
using iSpyApplication.Utilities;

namespace iSpyApplication.Cloud
{
Expand Down Expand Up @@ -73,7 +74,7 @@ public static bool Authorise()
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex);
Logger.LogExceptionToFile(ex);
return false;
}
return true;
Expand Down Expand Up @@ -110,7 +111,7 @@ public static bool Authorised
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex);
Logger.LogExceptionToFile(ex);
}
return false;
}
Expand All @@ -120,7 +121,7 @@ public static string Upload(string filename, string path)
{
if (!Authorised)
{
MainForm.LogMessageToFile("Authorise dropbox in settings");
Logger.LogMessageToFile("Authorise dropbox in settings");
return LocRm.GetString("CloudAddSettings");
}
if (UploadList.SingleOrDefault(p => p.SourceFilename == filename) != null)
Expand Down Expand Up @@ -193,11 +194,11 @@ private static void Upload(object state)
{
string p = "/" + entry.DestinationPath.Replace("\\", "/").Trim('/') + "/";
var r = Service.UploadFile(p, fi.Name, stream);
MainForm.LogMessageToFile("Uploaded to dropbox: /iSpy" + r.Path);
Logger.LogMessageToFile("Uploaded to dropbox: /iSpy" + r.Path);
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex);
Logger.LogExceptionToFile(ex);
}
}
Upload(null);
Expand Down
9 changes: 5 additions & 4 deletions Cloud/YouTubeUploader.cs
Expand Up @@ -11,6 +11,7 @@
using Google.Apis.Util.Store;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
using iSpyApplication.Utilities;

namespace iSpyApplication.Cloud
{
Expand Down Expand Up @@ -131,7 +132,7 @@ public static bool Authorise()
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex);
Logger.LogExceptionToFile(ex);
return false;

}
Expand Down Expand Up @@ -212,7 +213,7 @@ private static void Upload(object state)
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex);
Logger.LogExceptionToFile(ex);
}
Upload(null);
}
Expand All @@ -234,7 +235,7 @@ static void VideosInsertRequestProgressChanged(IUploadProgress progress)
break;

case UploadStatus.Failed:
MainForm.LogMessageToFile($"Upload to YouTube failed ({progress.Exception})");
Logger.LogMessageToFile($"Upload to YouTube failed ({progress.Exception})");
break;
}
}
Expand All @@ -244,7 +245,7 @@ static void VideosInsertRequestResponseReceived(Video video)
string msg = "YouTube video uploaded: <a href=\"http://www.youtube.com/watch?v=" + video.Id + "\">" +
video.Id + "</a>";
msg += " ("+video.Status.PrivacyStatus+")";
MainForm.LogMessageToFile(msg);
Logger.LogMessageToFile(msg);
_uploaded = true;
}

Expand Down
3 changes: 2 additions & 1 deletion Controls/Camera.cs
Expand Up @@ -12,6 +12,7 @@
using AForge.Imaging.Filters;
using iSpyApplication.Sources;
using iSpyApplication.Sources.Video;
using iSpyApplication.Utilities;
using iSpyApplication.Vision;
using Point = System.Drawing.Point;

Expand Down Expand Up @@ -620,7 +621,7 @@ private void PiP(Bitmap bmp)
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex);
Logger.LogExceptionToFile(ex);
}
}

Expand Down
13 changes: 7 additions & 6 deletions Controls/CameraWindow.cs
Expand Up @@ -25,6 +25,7 @@
using iSpyApplication.Sources.Audio;
using iSpyApplication.Sources.Video;
using iSpyApplication.Sources.Video.Ximea;
using iSpyApplication.Utilities;
using iSpyApplication.Vision;
using iSpyPRO.DirectShow;
using iSpyPRO.DirectShow.Internals;
Expand Down Expand Up @@ -590,7 +591,7 @@ public CameraWindow(objectsCamera cam, MainForm mainForm)

void CameraWindow_ErrorHandler(string message)
{
MainForm.LogErrorToFile(Camobject.name+": "+message);
Logger.LogErrorToFile(Camobject.name+": "+message);
}

private Thread _tFiles;
Expand Down Expand Up @@ -2835,7 +2836,7 @@ public void OpenWebInterface()
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex,"open web browser");
Logger.LogExceptionToFile(ex,"open web browser");
}
}
}
Expand Down Expand Up @@ -2966,7 +2967,7 @@ private void Record()
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex, "Generating external link to file");
Logger.LogExceptionToFile(ex, "Generating external link to file");
}
DoAlert("recordingstarted", linktofile);
}
Expand Down Expand Up @@ -3199,7 +3200,7 @@ private void Record()
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex);
Logger.LogExceptionToFile(ex);
}
}

Expand Down Expand Up @@ -3393,7 +3394,7 @@ private void AlertThread(string mode, string msg, int oid)
string l = mode + ": " + Camobject.name;
if (msg != "")
l += " message: " + msg;
MainForm.LogMessageToFile(l);
Logger.LogMessageToFile(l);

Bitmap bmp = null;
if (mode == "alert")
Expand Down Expand Up @@ -3424,7 +3425,7 @@ private void AlertThread(string mode, string msg, int oid)
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex);
Logger.LogExceptionToFile(ex);
}
}

Expand Down
3 changes: 2 additions & 1 deletion Controls/FTPConfig.cs
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Windows.Forms;
using iSpyApplication.Properties;
using iSpyApplication.Utilities;

namespace iSpyApplication.Controls
{
Expand Down Expand Up @@ -97,7 +98,7 @@ private void btnTest_Click(object sender, EventArgs e)
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex);
Logger.LogExceptionToFile(ex);
MessageBox.Show(ex.Message);
}
imageStream.Close();
Expand Down
3 changes: 2 additions & 1 deletion Controls/FloorPlan.cs
Expand Up @@ -6,6 +6,7 @@
using System.Threading;
using System.Windows.Forms;
using AForge.Imaging.Filters;
using iSpyApplication.Utilities;

namespace iSpyApplication.Controls
{
Expand Down Expand Up @@ -470,7 +471,7 @@ protected override void OnPaint(PaintEventArgs pe)
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex);
Logger.LogExceptionToFile(ex);
}

if (_mouseMove > Helper.Now.AddSeconds(-3) && MainForm.Conf.ShowOverlayControls)
Expand Down
3 changes: 2 additions & 1 deletion Controls/GridView.cs
Expand Up @@ -4,6 +4,7 @@
using System.Drawing.Drawing2D;
using System.Linq;
using System.Windows.Forms;
using iSpyApplication.Utilities;
using Timer = System.Timers.Timer;

namespace iSpyApplication.Controls
Expand Down Expand Up @@ -655,7 +656,7 @@ private void DoPaint(PaintEventArgs pe)
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex);
Logger.LogExceptionToFile(ex);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Controls/PreviewBox.cs
Expand Up @@ -227,7 +227,7 @@ public void PlayMedia(Enums.PlaybackMode mode)
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex);
Logger.LogExceptionToFile(ex);
MessageBox.Show(LocRm.GetString("NoPlayerForThisFile"));
}
break;
Expand Down
1 change: 1 addition & 0 deletions Controls/SelectObjects.cs
Expand Up @@ -61,6 +61,7 @@ private void button1_Click(object sender, EventArgs e)
break;
}
}
DialogResult = DialogResult.OK;
Close();
}

Expand Down

0 comments on commit 33c2879

Please sign in to comment.