mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-15 12:45:01 +00:00
feat: JSON conversion improvements for log items
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using ICD.Common.Properties;
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Converters;
|
||||||
|
|
||||||
namespace ICD.Common.Utils.Services.Logging
|
namespace ICD.Common.Utils.Services.Logging
|
||||||
{
|
{
|
||||||
@@ -17,12 +18,12 @@ namespace ICD.Common.Utils.Services.Logging
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the log time in UTC.
|
/// Gets the log time in UTC.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
|
||||||
public DateTime Timestamp { get { return m_Timestamp; } }
|
public DateTime Timestamp { get { return m_Timestamp; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get/Set for severity level.
|
/// Get/Set for severity level.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
public eSeverity Severity { get { return m_Severity; } }
|
public eSeverity Severity { get { return m_Severity; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -40,10 +41,22 @@ namespace ICD.Common.Utils.Services.Logging
|
|||||||
/// <param name="severity">Severity Level, between 0 and 7</param>
|
/// <param name="severity">Severity Level, between 0 and 7</param>
|
||||||
/// <param name="message">Error message text</param>
|
/// <param name="message">Error message text</param>
|
||||||
public LogItem(eSeverity severity, string message)
|
public LogItem(eSeverity severity, string message)
|
||||||
|
: this(IcdEnvironment.GetUtcTime(), severity, message)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new LogItem object with the specified values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="timestamp"></param>
|
||||||
|
/// <param name="severity">Severity Level, between 0 and 7</param>
|
||||||
|
/// <param name="message">Error message text</param>
|
||||||
|
[JsonConstructor]
|
||||||
|
public LogItem(DateTime timestamp, eSeverity severity, string message)
|
||||||
{
|
{
|
||||||
m_Severity = severity;
|
m_Severity = severity;
|
||||||
m_Message = message;
|
m_Message = message;
|
||||||
m_Timestamp = IcdEnvironment.GetUtcTime();
|
m_Timestamp = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -72,6 +85,11 @@ namespace ICD.Common.Utils.Services.Logging
|
|||||||
return !a1.Equals(a2);
|
return !a1.Equals(a2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if this instance is equal to the given object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="other"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public bool Equals(LogItem other)
|
public bool Equals(LogItem other)
|
||||||
{
|
{
|
||||||
return m_Severity == other.m_Severity &&
|
return m_Severity == other.m_Severity &&
|
||||||
|
|||||||
Reference in New Issue
Block a user