Merge remote-tracking branch 'origin/feat/logs' into ConnectPro_v1.2

This commit is contained in:
Chris Cameron
2019-04-16 14:01:11 -04:00
5 changed files with 58 additions and 31 deletions

View File

@@ -20,9 +20,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
</ItemGroup>
<ItemGroup>

View File

@@ -39,7 +39,7 @@
<None Remove="Properties\ControlSystem.cfg" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SQLite" Version="2.2.1" />
<PackageReference Include="Microsoft.Data.SQLite" Version="2.2.3" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="System.Net.NetworkInformation" Version="4.3.0" />

View File

@@ -17,5 +17,10 @@ namespace ICD.Common.Utils.IO
public IcdStreamWriter(StreamWriter baseStreamWriter) : base(baseStreamWriter)
{
}
public void WriteLine(string value)
{
WrappedStreamWriter.WriteLine(value);
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using ICD.Common.Properties;
using ICD.Common.Utils.Extensions;
@@ -61,10 +62,24 @@ namespace ICD.Common.Utils
{
get
{
if (IcdEnvironment.RuntimeEnvironment == IcdEnvironment.eRuntimeEnvironment.SimplSharpProMono)
return Join(RootConfigPath, "ProgramConfig");
string directoryName;
switch (IcdEnvironment.RuntimeEnvironment)
{
case IcdEnvironment.eRuntimeEnvironment.SimplSharp:
case IcdEnvironment.eRuntimeEnvironment.SimplSharpPro:
case IcdEnvironment.eRuntimeEnvironment.Standard:
directoryName = string.Format("Program{0:D2}Config", ProgramUtils.ProgramNumber);
break;
case IcdEnvironment.eRuntimeEnvironment.SimplSharpProMono:
directoryName = "ProgramConfig";
break;
default:
throw new ArgumentOutOfRangeException();
}
string directoryName = string.Format("Program{0:D2}Config", ProgramUtils.ProgramNumber);
return Join(RootConfigPath, directoryName);
}
}
@@ -87,6 +102,37 @@ namespace ICD.Common.Utils
[PublicAPI]
public static string ProgramLibPath { get { return Join(ProgramConfigPath, "Lib"); } }
/// <summary>
/// Returns the absolute path to the logs directory.
/// </summary>
/// <value></value>
[PublicAPI]
public static string ProgramLogsPath
{
get
{
string directoryName;
switch (IcdEnvironment.RuntimeEnvironment)
{
case IcdEnvironment.eRuntimeEnvironment.SimplSharp:
case IcdEnvironment.eRuntimeEnvironment.SimplSharpPro:
case IcdEnvironment.eRuntimeEnvironment.Standard:
directoryName = string.Format("Program{0:D2}Logs", ProgramUtils.ProgramNumber);
break;
case IcdEnvironment.eRuntimeEnvironment.SimplSharpProMono:
directoryName = "ProgramLogs";
break;
default:
throw new ArgumentOutOfRangeException();
}
return Join(RootConfigPath, directoryName);
}
}
#endregion
#region Methods

View File

@@ -1,5 +1,4 @@
using System;
using System.Text;
using ICD.Common.Properties;
namespace ICD.Common.Utils.Services.Logging
@@ -21,11 +20,6 @@ namespace ICD.Common.Utils.Services.Logging
[PublicAPI]
public DateTime Timestamp { get { return m_Timestamp; } }
/// <summary>
/// Gets the log time in local time.
/// </summary>
public DateTime LocalTimestamp { get { return Timestamp.ToLocalTime(); } }
/// <summary>
/// Get/Set for severity level.
/// </summary>
@@ -56,24 +50,6 @@ namespace ICD.Common.Utils.Services.Logging
#region Methods
/// <summary>
/// Return the text format to send to Fusion
/// </summary>
/// <returns>text format for fusion, including timestamp, severity, and message</returns>
[PublicAPI]
public string GetFusionLogText()
{
StringBuilder s = new StringBuilder();
s.Append(Timestamp.ToString("yyyyMMddHHmmss"));
s.Append("||");
s.Append((int)Severity);
s.Append("||");
s.Append(Message);
return s.ToString();
}
/// <summary>
/// Implementing default equality.
/// </summary>