-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Seek on a file pointer #1
Comments
You could implement it by extending class SeekableIterator extends LogIterator
{
/**
* @var resource
*/
private $fileHandler;
/**
* @var int
*/
private $seek;
/**
* @param int $seek
*/
public function setSeek($seek)
{
$this->seek = $seek;
}
/**
* {@inheritdoc}
*/
protected function getFileHandler()
{
if ($this->fileHandler !== null) {
return $this->fileHandler;
}
$this->fileHandler = parent::getFileHandler();
if ($this->seek !== null) {
fseek($this->fileHandler, $this->seek);
}
return $this->fileHandler;
}
} If you think it's worth to have it built-in in the package let me know. Or create a Pull Request :) |
This is perfect, I implemented it as a hack but will do with this piece of code and test. Thanks! |
Glad it helped. What is your use case? Do you want to get log messages in nearly real-time? |
I am actually using NGINX to collect webhook calls from a mailing application (http://www.activecampaign.com/api/webhooks.php). Running the parser every minute from a cronjob I take the logs entries and send them to an InfluxDB database and then get them on a Grafana dashboard. I'll probably open source the whole thing. Thanks for your help! |
Is it possible to implement seek on a file pointer?
This is needed to parse continuously updating log files, where items have been added since last parse.
The text was updated successfully, but these errors were encountered: