Closed jmcbee closed 9 years ago
You can do this quite easily using regular expressions. I wrote a class for doing just this but unfortunately I can't share it due to company restrictions.
What exactly do you need because I can share some details with you :)
Definitely - although I'm not sure it qualifies as an issue for KLogger :)
$matches = [];
$lines = file('log.txt');
foreach ($lines as $line) {
$matched = preg_match('/(some)(regex)(here)/', $line, $matches);
if ($matched) {
// do something with the matches - $matches[1], $matches[2], etc
}
}
if ($match) { /* ... */ }
Where does your $match
come from? :)
although I'm not sure it qualifies as an issue for KLogger :)
Also, wanted to say that there is no real place to ask questions about a project (not talking about KLogger specifically). Gitter tries to solve the problem, but it is not used by a lot of projects, and the chat format isn't perfect.
Typo, that should be $matched
(fixed)
@katzgrau: Maybe we can setup a sub-repo for discussions? No code just a place for people to ask questions and what not :)
Perhaps even move this project to its own Github page so we can host stuff like a parser as well? I'm sure I can refactor the parser to a point where I could share it.
Just a wild idea...?
Right, a simple regex should've done it. What was I thinking? Thanks.
If you need any help just ping me :)
Hello,
Is there a way to parse the lines of a logfile given that, I know the format used to write these lines?
Thanks.