aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Logging
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-01-21 18:27:13 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-01-21 18:27:13 +0200
commitde5315c050369dd7d2cc7cdc2b82e9cde0d6da24 (patch)
tree2cf2436f58182e3841471880cee90b0993c9e033 /Software/Visual_Studio/Tango.Logging
parente1506d483f8f7beadb1367d6a00acfb4754183fc (diff)
downloadTango-de5315c050369dd7d2cc7cdc2b82e9cde0d6da24.tar.gz
Tango-de5315c050369dd7d2cc7cdc2b82e9cde0d6da24.zip
Testing some external bridge communication..
Implemented external bridge application logs routing !!!
Diffstat (limited to 'Software/Visual_Studio/Tango.Logging')
-rw-r--r--Software/Visual_Studio/Tango.Logging/ExceptionLogItem.cs1
-rw-r--r--Software/Visual_Studio/Tango.Logging/LogItemBase.cs39
-rw-r--r--Software/Visual_Studio/Tango.Logging/LogManager.cs9
-rw-r--r--Software/Visual_Studio/Tango.Logging/MessageLogItem.cs1
4 files changed, 49 insertions, 1 deletions
diff --git a/Software/Visual_Studio/Tango.Logging/ExceptionLogItem.cs b/Software/Visual_Studio/Tango.Logging/ExceptionLogItem.cs
index d2a1a352d..7c325ee19 100644
--- a/Software/Visual_Studio/Tango.Logging/ExceptionLogItem.cs
+++ b/Software/Visual_Studio/Tango.Logging/ExceptionLogItem.cs
@@ -10,6 +10,7 @@ namespace Tango.Logging
/// <summary>
/// Represents an exception log item.
/// </summary>
+ [Serializable]
public class ExceptionLogItem : LogItemBase
{
/// <summary>
diff --git a/Software/Visual_Studio/Tango.Logging/LogItemBase.cs b/Software/Visual_Studio/Tango.Logging/LogItemBase.cs
index b914a33ef..f89b73b40 100644
--- a/Software/Visual_Studio/Tango.Logging/LogItemBase.cs
+++ b/Software/Visual_Studio/Tango.Logging/LogItemBase.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
+using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading.Tasks;
@@ -11,14 +12,21 @@ namespace Tango.Logging
/// <summary>
/// Represents a base class for log items.
/// </summary>
+ [Serializable]
public abstract class LogItemBase : INotifyPropertyChanged
{
private static String base_path;
+ [NonSerialized]
+ private Object _logObject;
/// <summary>
/// Gets or sets an optional log object.
/// </summary>
- public Object LogObject { get; set; }
+ public Object LogObject
+ {
+ get { return _logObject; }
+ set { _logObject = value; }
+ }
/// <summary>
/// Gets or sets the caller method adding the exception.
@@ -87,6 +95,35 @@ namespace Tango.Logging
}
/// <summary>
+ /// Serializes this log item using <see cref="BinaryFormatter"/>.
+ /// </summary>
+ /// <returns></returns>
+ public byte[] Serialize()
+ {
+ using (MemoryStream ms = new MemoryStream())
+ {
+ BinaryFormatter f = new BinaryFormatter();
+ f.Serialize(ms, this);
+ return ms.ToArray();
+ }
+ }
+
+ /// <summary>
+ /// Deserializes the specified data using <see cref="BinaryFormatter"/> to create a log item.
+ /// </summary>
+ /// <param name="data">The data.</param>
+ /// <returns></returns>
+ public static LogItemBase Deserialize(byte[] data)
+ {
+ using (MemoryStream ms = new MemoryStream(data))
+ {
+ ms.Position = 0;
+ BinaryFormatter f = new BinaryFormatter();
+ return f.Deserialize(ms) as LogItemBase;
+ }
+ }
+
+ /// <summary>
/// Raises the property changed event.
/// </summary>
/// <param name="propName">Name of the property.</param>
diff --git a/Software/Visual_Studio/Tango.Logging/LogManager.cs b/Software/Visual_Studio/Tango.Logging/LogManager.cs
index 04c66a71f..98bcaaa28 100644
--- a/Software/Visual_Studio/Tango.Logging/LogManager.cs
+++ b/Software/Visual_Studio/Tango.Logging/LogManager.cs
@@ -190,6 +190,15 @@ namespace Tango.Logging
}
/// <summary>
+ /// Appends the specified log item.
+ /// </summary>
+ /// <param name="logItem">The log item.</param>
+ public void Log(LogItemBase logItem)
+ {
+ AppendLog(logItem);
+ }
+
+ /// <summary>
/// Logs the current referenced assemblies in the app domain.
/// </summary>
public void LogReferencedAssemblies()
diff --git a/Software/Visual_Studio/Tango.Logging/MessageLogItem.cs b/Software/Visual_Studio/Tango.Logging/MessageLogItem.cs
index f45aa8cea..b0b3e24ae 100644
--- a/Software/Visual_Studio/Tango.Logging/MessageLogItem.cs
+++ b/Software/Visual_Studio/Tango.Logging/MessageLogItem.cs
@@ -10,6 +10,7 @@ namespace Tango.Logging
/// <summary>
/// Represents an exception log item.
/// </summary>
+ [Serializable]
public class MessageLogItem : LogItemBase
{
private String _message;