Wasatch.NET 2.4.14
.NET application driver for Wasatch Photonics spectrometers
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Properties | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
WasatchNET.Logger Class Reference

Singleton used throughout WasatchNET for logging and debugging. More...

Inheritance diagram for WasatchNET.Logger:
[legend]
Collaboration diagram for WasatchNET.Logger:
[legend]

Public Member Functions

void close ()
 
void debug (string fmt, params Object[] obj)
 log a debug message
 
bool debugEnabled ()
 Whether debugging is enabled.
 
bool error (string fmt, params Object[] obj)
 log an error message
 
List< string > getErrors ()
 
string getLastError ()
 peel-off the most recent error
 
bool hasError ()
 whether any recent errors have occurred
 
void header (string fmt, params Object[] obj)
 
void hexdump (byte[] buf, string prefix="")
 
void info (string fmt, params Object[] obj)
 log an info message
 
void logString (LogLevel lvl, string msg)
 log a string at arbitrary level w/o arguments
 
void save (string pathname)
 write TextBox contents to a text file
 
void setPathname (string path)
 If you'd like log messages written to a text file, specify the path here.
 
void setTextBox (TextBox tb)
 If you're developing in WinForms, pass a TextBook into the Logger for instant visualization!
 
void debug (string fmt, params Object[] obj)
 log a debug message
 
bool debugEnabled ()
 Whether debugging is enabled.
 
bool error (string fmt, params Object[] obj)
 log an error message
 
string getLastError ()
 peel-off the most recent error
 
bool hasError ()
 whether any recent errors have occurred
 
void hexdump (byte[] buf, string prefix="")
 
void info (string fmt, params Object[] obj)
 log an info message
 
void logString (LogLevel lvl, string msg)
 log a string at arbitrary level w/o arguments
 
void save (string pathname)
 write TextBox contents to a text file
 
void setPathname (string path)
 If you'd like log messages written to a text file, specify the path here.
 
void setTextBox (TextBox tb)
 If you're developing in WinForms, pass a TextBook into the Logger for instant visualization!
 

Static Public Member Functions

static Logger getInstance ()
 

Properties

LogLevel level [get, set]
 
- Properties inherited from WasatchNET.ILogger
LogLevel level [get, set]
 

Private Member Functions

string getTimestamp ()
 
void log (LogLevel lvl, string fmt, params Object[] obj)
 
 Logger ()
 

Private Attributes

LogLevel _level = LogLevel.INFO
 
int errorCount
 
LinkedList< string > errors = new LinkedList<string>()
 
StreamWriter outfile
 
TextBox textBox = null
 

Static Private Attributes

static readonly Logger instance = new Logger()
 
const int MAX_ERRORS = 100
 

Detailed Description

Singleton used throughout WasatchNET for logging and debugging.

Note that if running applications using Wasatch.NET from within Visual Studio, log messages should be visible at the Console Output, even if no TextBox or Path has been set.

Constructor & Destructor Documentation

◆ Logger()

WasatchNET.Logger.Logger ( )
inlineprivate

Member Function Documentation

◆ close()

void WasatchNET.Logger.close ( )
inline

◆ debug()

void WasatchNET.Logger.debug ( string  fmt,
params Object[]  obj 
)
inline

log a debug message

Parameters
fmtsee String.Format() fmt
objsee String.Format() args

Implements WasatchNET.ILogger.

◆ debugEnabled()

bool WasatchNET.Logger.debugEnabled ( )
inline

Whether debugging is enabled.

Returns
true if debugging is enabled

Implements WasatchNET.ILogger.

◆ error()

bool WasatchNET.Logger.error ( string  fmt,
params Object[]  obj 
)
inline

log an error message

Parameters
fmtsee String.Format() fmt
objsee String.Format() args
Returns
false, because that's convenient for many cases

Implements WasatchNET.ILogger.

◆ getErrors()

List< string > WasatchNET.Logger.getErrors ( )
inline

◆ getInstance()

static Logger WasatchNET.Logger.getInstance ( )
inlinestatic

◆ getLastError()

string WasatchNET.Logger.getLastError ( )
inline

peel-off the most recent error

Returns
the most recent error message

other errors will remain in the "recent" queue; this does not necessary clear hasError()

Implements WasatchNET.ILogger.

◆ getTimestamp()

string WasatchNET.Logger.getTimestamp ( )
inlineprivate

◆ hasError()

bool WasatchNET.Logger.hasError ( )
inline

whether any recent errors have occurred

Returns
true if one or more error messages are pending retrieval

Implements WasatchNET.ILogger.

◆ header()

void WasatchNET.Logger.header ( string  fmt,
params Object[]  obj 
)
inline

◆ hexdump()

void WasatchNET.Logger.hexdump ( byte[]  buf,
string  prefix = "" 
)
inline

Implements WasatchNET.ILogger.

◆ info()

void WasatchNET.Logger.info ( string  fmt,
params Object[]  obj 
)
inline

log an info message

Parameters
fmtsee String.Format() fmt
objsee String.Format() args

Implements WasatchNET.ILogger.

◆ log()

void WasatchNET.Logger.log ( LogLevel  lvl,
string  fmt,
params Object[]  obj 
)
inlineprivate

◆ logString()

void WasatchNET.Logger.logString ( LogLevel  lvl,
string  msg 
)
inline

log a string at arbitrary level w/o arguments

Parameters
lvla valid LogLevel
msgmessage

Provided for client languages that have difficulty passing an empty params Object[] array

Implements WasatchNET.ILogger.

◆ save()

void WasatchNET.Logger.save ( string  pathname)
inline

write TextBox contents to a text file

Parameters
pathnamepath to create

only works if setTextBox() has been called; otherwise, use setPathname()

Implements WasatchNET.ILogger.

◆ setPathname()

void WasatchNET.Logger.setPathname ( string  path)
inline

If you'd like log messages written to a text file, specify the path here.

Make sure the directory exists and is writable.

Parameters
pathoutput path (e.g. "\\tmp\\WasatchNET.log")

Implements WasatchNET.ILogger.

◆ setTextBox()

void WasatchNET.Logger.setTextBox ( TextBox  tb)
inline

If you're developing in WinForms, pass a TextBook into the Logger for instant visualization!

Parameters
tbthe TextBox control where you would like log messages to appear

Implements WasatchNET.ILogger.

Member Data Documentation

◆ _level

LogLevel WasatchNET.Logger._level = LogLevel.INFO
private

◆ errorCount

int WasatchNET.Logger.errorCount
private

◆ errors

LinkedList<string> WasatchNET.Logger.errors = new LinkedList<string>()
private

◆ instance

readonly Logger WasatchNET.Logger.instance = new Logger()
staticprivate

◆ MAX_ERRORS

const int WasatchNET.Logger.MAX_ERRORS = 100
staticprivate

◆ outfile

StreamWriter WasatchNET.Logger.outfile
private

◆ textBox

TextBox WasatchNET.Logger.textBox = null
private

Property Documentation

◆ level

LogLevel WasatchNET.Logger.level
getset

Implements WasatchNET.ILogger.


The documentation for this class was generated from the following file: