cant find keyword

#1 · closed · 2 comments

View on GitHub ↗

da-w-xu

Hi yichao! i'm trying to find some arbritrary keywords in my file (attached) , via ``` /var/log # curl 'localhost:8080/log/read?file=install.log&mode=stream&limit=100000&keyword=dax' event: pagination data: {"hasMore":false} /var/log # curl 'localhost:8080/log/read?file=install.log&mode=stream&limit=100000&keyword=2023' event: pagination data: {"hasMore":false} ``` but they both return nothing, where as grep finds it correctly ``` /var/log # grep dax /var/log/install.log dax123 /var/log # grep 2023 /var/log/install.log 2023-05-10 13:44:08-07 K27K2J-T7Jh installer[36653]: zero 0.00 seconds 2023-05-10 13:44:08-07 K27K2J-T7Jh installer[36653]: install 1.21 seconds 2023-05-10 13:44:09-07 K27K2J-T7Jh installer[36687]: Starting installation: 2023-05-10 13:44:09-07 K27K2J-T7Jh installer[36687]: Configuring volume "Macintosh HD" ``` [install.log](https://github.com/user-attachments/files/18296705/install.log)

Comments

devMYC

Let me test using your log file.

devMYC

Seems like there might be lines in log file longer than the buffer size I used (i.e. 4096 bytes) so the searching terminated because a newline was not detected in the buffer. I mentioned this assumption in the README file. Increased the buffer size to 8192 returned the expected line. ```diff -const BUF_SIZE = 4096; +const BUF_SIZE = 8192; ``` ``` $ curl -i 'localhost:8080/log/read?file=install.log&mode=stream&limit=10&keyword=dax' HTTP/1.1 200 OK x-accel-buffering: no content-type: text/event-stream cache-control: no-cache Date: Fri, 03 Jan 2025 05:49:47 GMT Connection: keep-alive Keep-Alive: timeout=5 Transfer-Encoding: chunked event: log data: {"line":"dax123"} event: pagination data: {"hasMore":false} ```