Skip to content

Commit d2057b6

Browse files
committed
Fix path slashes per OS
1 parent 794f4ed commit d2057b6

File tree

1 file changed

+5
-23
lines changed

1 file changed

+5
-23
lines changed

Aeon.Library/Utilities/Logger.cs

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,6 @@ public static class Logging
2727
/// </summary>
2828
public static string TranscriptModelFile { get; set; }
2929
/// <summary>
30-
/// Whether or not running tests.
31-
/// </summary>
32-
public static bool TestExecution { get; set; }
33-
/// <summary>
34-
/// The path for logging and transcripting when testing.
35-
/// </summary>
36-
public static string TestingPath { get; set; }
37-
/// <summary>
38-
/// The file path for executing assemblies. Set <see cref="TestExecution"/> to true and indicate the <see cref="TestingPath"/>.
39-
/// </summary>
40-
public static string FilePath()
41-
{
42-
if (TestExecution)
43-
return TestingPath;
44-
return Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..\\..\\..\\"));
45-
}
46-
/// <summary>
4730
/// The type of log to write.
4831
/// </summary>
4932
public enum LogType
@@ -266,7 +249,7 @@ public static void WriteLog(string message, LogType logType, LogCaller caller)
266249
}
267250
LastMessage = message;
268251
// Use FilePath() when outside of a test framework.
269-
StreamWriter stream = new StreamWriter(FilePath() + @"\logs\" + LogModelFile + @".txt", true);
252+
StreamWriter stream = new StreamWriter(Path.Combine(Environment.CurrentDirectory, "logs", LogModelFile + @".txt"));
270253
switch (logType)
271254
{
272255
case LogType.Error:
@@ -301,7 +284,7 @@ public static void RecordTranscript(string message, int fileNumber, bool insertN
301284
{
302285
try
303286
{
304-
StreamWriter stream = new StreamWriter(FilePath() + @"\logs\transcript.txt", true);
287+
StreamWriter stream = new StreamWriter(Path.Combine(Environment.CurrentDirectory, "logs", TranscriptModelFile + @".txt"));
305288
if (!_fileCreated && fileNumber == 0)
306289
{
307290
// File has not been created previously, write the header to the file.
@@ -312,7 +295,7 @@ public static void RecordTranscript(string message, int fileNumber, bool insertN
312295
if (fileNumber != 0)
313296
{
314297
stream.Dispose();
315-
stream = new StreamWriter(FilePath() + @"\logs\transcript" + fileNumber + ".txt", true);
298+
stream = new StreamWriter(Path.Combine(Environment.CurrentDirectory, "logs", TranscriptModelFile + fileNumber + @".txt"));
316299
if (!_fileCreated)
317300
{
318301
stream.WriteLine(@"August 2017" + Environment.NewLine + @"A transcript log for an interative conversation between two aeons, in pursuit of validation / critique of a paper as well as outlining an example of ethical application.");
@@ -343,8 +326,7 @@ public static void RecordTranscript(string message)
343326
}
344327
try
345328
{
346-
// Use FilePath() when outside of a test framework.
347-
StreamWriter stream = new StreamWriter(FilePath() + @"\logs\" + TranscriptModelFile + @".txt", true);
329+
StreamWriter stream = new StreamWriter(Path.Combine(Environment.CurrentDirectory, "logs", TranscriptModelFile + @".txt"));
348330
stream.WriteLine(DateTime.Now + " - " + message);
349331
stream.Close();
350332
}
@@ -360,7 +342,7 @@ public static void RecordTranscript(string message)
360342
/// <param name="objects">The objects.</param>
361343
public static void Debug(params object[] objects)
362344
{
363-
StreamWriter stream = new StreamWriter(FilePath() + @"\logs\debugdump.txt", true);
345+
StreamWriter stream = new StreamWriter(Path.Combine(Environment.CurrentDirectory, "logs", "debugdump" + @".txt"));
364346
foreach (object obj in objects)
365347
{
366348
stream.WriteLine(obj);

0 commit comments

Comments
 (0)