Class ParserFeedback
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)
Inherited Members
Namespace: TimeSeriesAnalysis.Utility
Assembly: TimeSeriesAnalysis.dll
Syntax
public class ParserFeedback
Constructors
| Edit this page View SourceParserFeedback(bool)
Constructor
Declaration
public ParserFeedback(bool doOutputAlsoToConsole = false)
Parameters
Type | Name | Description |
---|---|---|
bool | doOutputAlsoToConsole |
Methods
| Edit this page View SourceAddError(string)
Add an error message
Declaration
public void AddError(string message)
Parameters
Type | Name | Description |
---|---|---|
string | message |
AddFatalError(string)
Adds a fatal error
Declaration
public void AddFatalError(string message)
Parameters
Type | Name | Description |
---|---|---|
string | message |
AddInfo(string)
Adds an info message
Declaration
public void AddInfo(string message)
Parameters
Type | Name | Description |
---|---|---|
string | message |
AddWarning(string)
Adds a warning
Declaration
public void AddWarning(string message)
Parameters
Type | Name | Description |
---|---|---|
string | message |
Close()
Flushes all messages to file and closes file handlers.
Declaration
public void Close()
CloseCaseLogFile()
Close a log file belong to a perticular case
Declaration
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.
Declaration
public void CreateCaseLogFile(string caseName, int caseNum)
Parameters
Type | Name | Description |
---|---|---|
string | caseName | |
int | caseNum |
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
Declaration
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
Declaration
public void CreateCommonLogFile(string loggDir)
Parameters
Type | Name | Description |
---|---|---|
string | loggDir |
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)
Declaration
public void EnableConsoleOutput(bool doEnable = true)
Parameters
Type | Name | Description |
---|---|---|
bool | doEnable |
EnableDebugOutput(bool)
Enables or disables the output to Visual Studio debug window and to console out
Declaration
public void EnableDebugOutput(bool doEnable = true)
Parameters
Type | Name | Description |
---|---|---|
bool | doEnable |
GetFirstErrorOrWarning()
Intended for unit tests, get the first error or warning message
Declaration
public string GetFirstErrorOrWarning()
Returns
Type | Description |
---|---|
string |
GetListOfAllLogLinesAtOrAboveLevel(ParserfeedbackMessageLevel)
Returns all log lines at or above a specified level
Declaration
public List<string> GetListOfAllLogLinesAtOrAboveLevel(ParserfeedbackMessageLevel desiredLevel = ParserfeedbackMessageLevel.warn)
Parameters
Type | Name | Description |
---|---|---|
ParserfeedbackMessageLevel | desiredLevel |
Returns
Type | Description |
---|---|
List<string> |
GetListOfAllLogLinesAtOrBelowLevel(ParserfeedbackMessageLevel)
Returns all log lines at or belowe a specified level
Declaration
public List<string> GetListOfAllLogLinesAtOrBelowLevel(ParserfeedbackMessageLevel desiredLevel = ParserfeedbackMessageLevel.warn)
Parameters
Type | Name | Description |
---|---|---|
ParserfeedbackMessageLevel | desiredLevel |
Returns
Type | Description |
---|---|
List<string> |
GetListOfAllLogLinesOfLevel(ParserfeedbackMessageLevel)
Returns all log lines of a specified level
Declaration
public List<string> GetListOfAllLogLinesOfLevel(ParserfeedbackMessageLevel desiredLevel)
Parameters
Type | Name | Description |
---|---|---|
ParserfeedbackMessageLevel | desiredLevel |
Returns
Type | Description |
---|---|
List<string> |
GetLogFilePath()
Returns the path to which log files are written
Declaration
public string GetLogFilePath()
Returns
Type | Description |
---|---|
string |
GetLogFilename()
Returns the name of the current log file
Declaration
public string GetLogFilename()
Returns
Type | Description |
---|---|
string |
IsNumberOfErrorsAndWarningsZero()
For testing, this is a way to check that no errors or warnings have been given.
Declaration
public bool IsNumberOfErrorsAndWarningsZero()
Returns
Type | Description |
---|---|
bool |
ResetCounters()
Reset all error and warning counters
Declaration
public void ResetCounters()
SetCaseArray(string[])
If output is to be divided into multiple log files, set the names of each "case"
Declaration
public void SetCaseArray(string[] caseArray)
Parameters
Type | Name | Description |
---|---|---|
string[] | caseArray |