private void CheckMutex()
{
if (BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL > BonCodeAJP13LogLevels.BONCODEAJP13_NO_LOG)
{
bool initLogger = true;
string errMsg = "";
//if we have a log filter we need to satisfy it first, in that case only log when we have a match pattern
if (BonCodeAJP13Settings.BONCODEAJP13_LOG_IPFILTER.Length > 0 && p_ClientIp.Length > 0)
{
try
{
//test whether part or parts of clientIp match the filter condition. If we have no match, we need to skip logging.
MatchCollection matches = Regex.Matches(p_ClientIp, BonCodeAJP13Settings.BONCODEAJP13_LOG_IPFILTER, RegexOptions.IgnorePatternWhitespace);
if (matches.Count == 0)
{
initLogger = false;
}
}
catch (Exception e)
{
//for any exception we will initialize logging anyway because of the initLogger flag
errMsg = "Your regular expression provided in setting LogIPFilter raised exception:" + e.Message;
}
}
if (initLogger)
{
//default log file name is BonCodeAJP13ConnectionLog.txt in directory of DLL or Windows
p_Logger = new BonCodeAJP13Logger(BonCodeAJP13Settings.BONCODEAJP13_LOG_FILE + p_LogFilePostFix + DateTime.Now.ToString("yyyyMMdd") + ".log", p_ConnectionMutex);
//if RegEx contained error message we will also write an error msg
if (errMsg.Length > 0)
{
p_Logger.LogMessage(errMsg);
}
}
}
}