Hi,
I need to filter log messages based on the log level and a text appearing in the log message. These messages are in the following form:
12/23/2009 17:33:26.379 [INFO] TMSNG.Main Channelset configured with url [http://172.16.34.4:8080/tms-flux/messagebroker/streamingamf] 12/23/2009 17:33:26.380 [DEBUG] org.springextensions.actionscript.core.command.CompositeCommand Executing composite command '[object CompositeCommand]' in sequence
I already have the code below that creates 2 regular expressions (one for the level and one for the text) but I was wondering how I could combine these into one. I tried several combinations, but since my regexp skills are non-existing I couldn't get this to work.
Any hints?
Code:
private function filterLogMessage(item:Object):Boolean {
var logMessage:String = String(item);
var levelFilter:String = getLevelFilter();
var levelRegExp:RegExp = new RegExp(levelFilter, "");
var textFilter:String = StringUtils.trim(filterTextInput.text);
var textRegExp:RegExp = new RegExp(textFilter, "");
var match:Boolean = (levelRegExp.test(logMessage) && textRegExp.test(logMessage));
return match;
}
private function getLevelFilter():String {
var result:String = "";
var selectedLevel:String = levelComboBox.selectedLabel;
switch (selectedLevel) {
case "DEBUG":
//result = "\\[(DEBUG|INFO|WARN|ERROR|FATAL)\\]";
break;
case "INFO":
result = "\\[(INFO|WARN|ERROR|FATAL)\\]";
break;
case "WARN":
result = "\\[(WARN|ERROR|FATAL)\\]";
break;
case "ERROR":
result = "\\[(ERROR|FATAL)\\]";
break;
case "FATAL":
result = "\\[(FATAL)\\]";
break;
}
return result;
}