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
doOutputAlsoToConsolebool
Methods
AddError(string)
Add an error message
public void AddError(string message)
Parameters
messagestring
AddFatalError(string)
Adds a fatal error
public void AddFatalError(string message)
Parameters
messagestring
AddInfo(string)
Adds an info message
public void AddInfo(string message)
Parameters
messagestring
AddWarning(string)
Adds a warning
public void AddWarning(string message)
Parameters
messagestring
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
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
loggDirstring
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
doEnablebool
EnableDebugOutput(bool)
Enables or disables the output to Visual Studio debug window and to console out
public void EnableDebugOutput(bool doEnable = true)
Parameters
doEnablebool
GetFirstErrorOrWarning()
Intended for unit tests, get the first error or warning message
public string GetFirstErrorOrWarning()
Returns
GetListOfAllLogLinesAtOrAboveLevel(ParserfeedbackMessageLevel)
Returns all log lines at or above a specified level
public List<string> GetListOfAllLogLinesAtOrAboveLevel(ParserfeedbackMessageLevel desiredLevel = ParserfeedbackMessageLevel.warn)
Parameters
desiredLevelParserfeedbackMessageLevel
Returns
GetListOfAllLogLinesAtOrBelowLevel(ParserfeedbackMessageLevel)
Returns all log lines at or belowe a specified level
public List<string> GetListOfAllLogLinesAtOrBelowLevel(ParserfeedbackMessageLevel desiredLevel = ParserfeedbackMessageLevel.warn)
Parameters
desiredLevelParserfeedbackMessageLevel
Returns
GetListOfAllLogLinesOfLevel(ParserfeedbackMessageLevel)
Returns all log lines of a specified level
public List<string> GetListOfAllLogLinesOfLevel(ParserfeedbackMessageLevel desiredLevel)
Parameters
desiredLevelParserfeedbackMessageLevel
Returns
GetLogFilePath()
Returns the path to which log files are written
public string GetLogFilePath()
Returns
GetLogFilename()
Returns the name of the current log file
public string GetLogFilename()
Returns
IsNumberOfErrorsAndWarningsZero()
For testing, this is a way to check that no errors or warnings have been given.
public bool IsNumberOfErrorsAndWarningsZero()
Returns
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
caseArraystring[]