Permalink
Browse files

fix log filtering

  • Loading branch information...
icewind1991 committed Dec 22, 2016
1 parent 2bcd915 commit 4095dfc62dcceb3c59a3f581baa5589737d0e6f3
View
@@ -152,7 +152,7 @@ export class App extends Component {
return (
<AppContainer appId="logreader">
<div>
{!this.props.inlineSettings ?
<SideBar><LogUploader
onLogFile={this.onLogFile}/>
@@ -169,7 +169,7 @@ export class App extends Component {
: <div/>}
{content}
</AppContainer>
</div>
);
}
}
View
@@ -12,8 +12,8 @@ export class LogSearch {
}
attach (search) {
search.setFilter('logreader', _.debounce((query) => {
if (query.length >= 3 || query === '') {
search.setFilter('settings', _.debounce((query) => {
if (query.length >= 3 || query == '') {
this.provider.query = query;
}
}, 250));
@@ -77,7 +77,10 @@ public function get($count = 50, $offset = 0) {
*/
public function search($query = '', $count = 50, $offset = 0) {
$iterator = $this->getLogIterator();
$iterator = new \LimitIterator($iterator, 0, 10000); // limit the number of message we search to avoid huge search times
$iterator->rewind();
$iterator = new SearchFilter($iterator, $query);
$iterator->rewind();
return $this->responseFromIterator($iterator, $count, $offset);
}
File renamed without changes.
@@ -33,11 +33,12 @@ class SearchFilter extends \FilterIterator {
private $levels;
/**
* @param LogIterator $iterator
* @param \Iterator $iterator
* @param string $query
*/
public function __construct(LogIterator $iterator, $query) {
public function __construct(\Iterator $iterator, $query) {
parent::__construct($iterator);
$this->rewind();
$this->query = strtolower($query);
$this->levels = ['Debug', 'Info', 'Warning', 'Error', 'Fatal'];
}
@@ -47,9 +48,12 @@ private function formatLevel($level) {
}
public function accept() {
$value = $this->getInnerIterator()->current();
return stripos($value->message, $this->query) !== false
|| stripos($value->app, $this->query) !== false
|| stripos($this->formatLevel($value->level), $this->query) !== false;
if (!$this->query) {
return true;
}
$value = $this->current();
return stripos($value['message'], $this->query) !== false
|| stripos($value['app'], $this->query) !== false
|| stripos($this->formatLevel($value['level']), $this->query) !== false;
}
}

0 comments on commit 4095dfc

Please sign in to comment.