/// <summary> /// Initializes the parameters, but does not open the logger. Init can be called multiple times. /// Remember to call base.Init() in your overriding member. /// </summary> /// <param name="i_Params"></param> /// <returns></returns> public virtual bool Init(ref ParamCollection i_Params) { bool bRet = true, bRes = true; string sParam = "", sThreadId = ""; LoggerThreadInfo ltiTmp = null; ThreadInfoDictSingleton oDict = null; try { sParam = eRequiredParams.ThreadId.ToString(); sThreadId = i_Params.Find(param => param.GetName() == sParam).GetValue(); oDict = ThreadInfoDictSingleton.GetInstance(); bRes = oDict.TryGetValue(sThreadId, out ltiTmp); if (!bRes) { ltiTmp = new LoggerThreadInfo(); oDict.Add(sThreadId, ltiTmp); ltiTmp.m_sThreadId = sThreadId; } lock (ltiTmp) // Technically it shouldn't be necessary to lock, but it can't hurt { // Pull the required params from the collection to the member variables, for easier access later. sParam = eRequiredParams.IpAddress.ToString(); ltiTmp.m_sIpAddress = i_Params.Find(param => param.GetName() == sParam).GetValue(); sParam = eRequiredParams.SessionId.ToString(); ltiTmp.m_sSessionId = i_Params.Find(param => param.GetName() == sParam).GetValue(); sParam = eRequiredParams.ComponentName.ToString(); ltiTmp.m_sComponentName = i_Params.Find(param => param.GetName() == sParam).GetValue(); sParam = eRequiredParams.VmcId.ToString(); ltiTmp.m_sVmcId = i_Params.Find(param => param.GetName() == sParam).GetValue(); } } catch { bRet = false; // Unnecessary if throwing an exception throw(new ArgumentException("Logger.Init: A required parameter was not included in i_Params: " + sParam)); } return(bRet); } // Init
/// <summary> /// /// </summary> /// <param name="i_Params"></param> /// <returns></returns> public override bool Init(ref ParamCollection i_Params) { bool bRet = true; base.Init(ref i_Params); SetLastError(0, ""); m_ParamCollection = i_Params; try { // Pull the additional params from the collection to the member variables, for easier access later. m_sPath = i_Params.Find(param => param.GetName() == eMoreParams.Path.ToString()).GetValue(); } catch { bRet = false; // Unnecessary if throwing an exception SetLastError(-1, "TsvAndStdoutLogger.Init: The parameter 'Path' was not specified in i_Params."); throw (new ArgumentException(m_sLastError)); } return(bRet); } // Init