-
Notifications
You must be signed in to change notification settings - Fork 90
Filters
Zubair Rehman edited this page May 3, 2019
·
1 revision
Flogs provide support to filter out logs and only fetch logs that you need based on different params. A complete list of params is mentioned below:
1. DBConstants.FIELD_ID;
2. DBConstants.FIELD_CLASSNAME;
3. DBConstants.FIELD_METHOD_NAME;
4. DBConstants.FIELD_TEXT;
5. DBConstants.FIELD_TIMESTAMP;
6. DBConstants.FIELD_EXCEPTION;
7. DBConstants.FIELD_DATA_LOG_TYPE;
8. DBConstants.FIELD_TIME_IN_MILLIS;
9. DBConstants.FIELD_LOG_LEVEL;
//creating list of filters
List<Filter> filters = List();
List<Filter> timestampFilters = List();
//check to see if dataLogsType is not null
if (dataLogsType != null && dataLogsType.length > 0) {
Filter dataLogTypeFilter =
Filter.inList(DBConstants.FIELD_DATA_LOG_TYPE, dataLogsType);
filters.add(dataLogTypeFilter);
}
//check to see if logLevels is not null
if (logLevels != null && logLevels.length > 0) {
Filter logLevelsFilter =
Filter.inList(DBConstants.FIELD_LOG_LEVEL, logLevels);
filters.add(logLevelsFilter);
}
//check to see if both start and end times are provided
if (startTimeInMillis != null && endTimeInMillis != null) {
timestampFilters = [
Filter.greaterThan(DBConstants.FIELD_TIME_IN_MILLIS, startTimeInMillis),
Filter.lessThan(DBConstants.FIELD_TIME_IN_MILLIS, endTimeInMillis)
];
filters.addAll(timestampFilters);
}
//check to see if user provided start time
if (startTimeInMillis != null) {
Filter startTimeFilter = Filter.greaterThan(
DBConstants.FIELD_TIME_IN_MILLIS, startTimeInMillis);
filters.add(startTimeFilter);
}
//check to see if user provided end time
if (endTimeInMillis != null) {
Filter endTimeFilter =
Filter.lessThan(DBConstants.FIELD_TIME_IN_MILLIS, endTimeInMillis);
filters.add(endTimeFilter);
}