Programmer's Guide (Supporting ADX v03.1.00) Manual

864 Brocade Virtual ADX XML API Programmer’s Guide
53-1003248-01
Example: Unbinding a real server from a VIP
B
// Name: OpenRCloseLog
//
// Description: This function will be called to open or close the log file.
//
// Parameters: bOpen - true/false
//
/////////////////////////////////////////////////////////////////////////////
public bool OpenRCloseLog(bool bOpen)
{
string sLogPath = "";
//get the full location of the assembly with DaoTests in it
string sfullPath =
System.Reflection.Assembly.GetAssembly(typeof(Utils)).Location;
//get the folder that's in
string sDirectory = Path.GetDirectoryName(sfullPath);
sLogPath = String.Format("{0}\\ConfigureSLB.txt", sDirectory);
//check whether m_StreamWriter object is null before opening the log
file
if (bOpen == true && m_StreamWriter == null)
{
m_FileStream = new FileStream(sLogPath, FileMode.OpenOrCreate |
FileMode.Append, FileAccess.Write);
m_StreamWriter = new StreamWriter(m_FileStream);
if (m_StreamWriter == null)
{
return false;
}
return true;
}
else
{
//Check the validity of the streamwriter before calling close
command
if (m_StreamWriter != null)
{
//Close the log file
m_StreamWriter.Close();
m_FileStream.Close();
m_FileStream = null;
m_StreamWriter = null;
}
}
return true;
}
/////////////////////////////////////////////////////////////////////////////
// Name: WL
//
// Description: This function to write the log message to the file.
//
// Parameters: sLogMessage - the log message to be written to the log file.
//
/////////////////////////////////////////////////////////////////////////////
public void WL(string sLogMessage, string sLogMessage1)
{
if (m_StreamWriter == null)
{
//Do not write the log if the log file is not opened