Table of Contents

Class ParserFeedback

Namespace
TimeSeriesAnalysis.Utility
Assembly
TimeSeriesAnalysis.dll

Utility class is responsible for collecting feedback lines, such as warnings,error or info text to either the console window, visual-studio output/debug window, to a file structure or all.

The class makes it easy to switch between displaying output to a console while debugging while to outputting to file when code moves to a server. Suitable for collecting debugging info from services that run many cases repeatedly.

log levels: INFO,WARN,ERROR,FATAL (no debug messages here)

public class ParserFeedback
Inheritance
ParserFeedback
Inherited Members

Constructors

ParserFeedback(bool)

Constructor

public ParserFeedback(bool doOutputAlsoToConsole = false)

Parameters

doOutputAlsoToConsole bool

Methods

AddError(string)

Add an error message

public void AddError(string message)

Parameters

message string

AddFatalError(string)

Adds a fatal error

public void AddFatalError(string message)

Parameters

message string

AddInfo(string)

Adds an info message

public void AddInfo(string message)

Parameters

message string

AddWarning(string)

Adds a warning

public void AddWarning(string message)

Parameters

message string

Close()

Flushes all messages to file and closes file handlers.

public void Close()

CloseCaseLogFile()

Close a log file belong to a perticular case

public void CloseCaseLogFile()

CreateCaseLogFile(string, int)

Creates a new empty log file for a specific case name. Calling this function before StoreMessage will cause all messages to be copied to it.

public void CreateCaseLogFile(string caseName, int caseNum)

Parameters

caseName string
caseNum int

CreateCommonHTMLfile()

Creates a html file, where is "case" is presented in an iframe- useful for quickly viewing many cases Needs SetCaseArray to be called first

public void CreateCommonHTMLfile()

CreateCommonLogFile(string)

Creates a new empty log file and, resets counters etc. This is a "common" file if no cases are specificed

public void CreateCommonLogFile(string loggDir)

Parameters

loggDir string

EnableConsoleOutput(bool)

Enable (or disable) console output - i.e. writing messages directly to screen (useful for debugging, but leave off if running on a server)

public void EnableConsoleOutput(bool doEnable = true)

Parameters

doEnable bool

EnableDebugOutput(bool)

Enables or disables the output to Visual Studio debug window and to console out

public void EnableDebugOutput(bool doEnable = true)

Parameters

doEnable bool

GetFirstErrorOrWarning()

Intended for unit tests, get the first error or warning message

public string GetFirstErrorOrWarning()

Returns

string

GetListOfAllLogLinesAtOrAboveLevel(ParserfeedbackMessageLevel)

Returns all log lines at or above a specified level

public List<string> GetListOfAllLogLinesAtOrAboveLevel(ParserfeedbackMessageLevel desiredLevel = ParserfeedbackMessageLevel.warn)

Parameters

desiredLevel ParserfeedbackMessageLevel

Returns

List<string>

GetListOfAllLogLinesAtOrBelowLevel(ParserfeedbackMessageLevel)

Returns all log lines at or belowe a specified level

public List<string> GetListOfAllLogLinesAtOrBelowLevel(ParserfeedbackMessageLevel desiredLevel = ParserfeedbackMessageLevel.warn)

Parameters

desiredLevel ParserfeedbackMessageLevel

Returns

List<string>

GetListOfAllLogLinesOfLevel(ParserfeedbackMessageLevel)

Returns all log lines of a specified level

public List<string> GetListOfAllLogLinesOfLevel(ParserfeedbackMessageLevel desiredLevel)

Parameters

desiredLevel ParserfeedbackMessageLevel

Returns

List<string>

GetLogFilePath()

Returns the path to which log files are written

public string GetLogFilePath()

Returns

string

GetLogFilename()

Returns the name of the current log file

public string GetLogFilename()

Returns

string

IsNumberOfErrorsAndWarningsZero()

For testing, this is a way to check that no errors or warnings have been given.

public bool IsNumberOfErrorsAndWarningsZero()

Returns

bool

ResetCounters()

Reset all error and warning counters

public void ResetCounters()

SetCaseArray(string[])

If output is to be divided into multiple log files, set the names of each "case"

public void SetCaseArray(string[] caseArray)

Parameters

caseArray string[]