-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathLogMessage.cs
More file actions
60 lines (57 loc) · 1.59 KB
/
LogMessage.cs
File metadata and controls
60 lines (57 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
using System;
using System.Collections.Generic;
using System.IO;
namespace SQLBench
{
//
// Written by the Microsoft CSS SQL Networking Team
//
// Wrapper class to log messages
//
class LogMessage
{
List<string> MessageLog;
string mySource;
public LogMessage(string MyProgSource)
{
//create a new List of strings to store messages
MessageLog = new List<string> { };
mySource = MyProgSource;
}
public void RecordMessage(string Message)
{
//add messages to list
//if run From Console also print line to screen
MessageLog.Add(Message);
if(mySource == "MyConsole")
Console.WriteLine(Message);
}
public void PrintMessage()
{
//no referances here so might remove this code
foreach(string a in MessageLog)
{
Console.WriteLine(a);
}
}
public void SaveLog(string outFile)
{
//Output List to text file
outFile = outFile + "\\TestLog.txt";
using (StreamWriter SW = new StreamWriter(outFile))
{
foreach (string a in MessageLog)
{
SW.WriteLine(a);
}
}
}
public string GetMessage()
{
//Reteave last sting added to list
return MessageLog[MessageLog.Count-1];
}
}
}