-
Notifications
You must be signed in to change notification settings - Fork 14
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
L-2183 Ensure flushed logs in long running scripts #22
Conversation
…discovery of options
16e8541
to
ffd1b13
Compare
Planning on releasing this as I've added a note into our PHP logging docs about terminating scripts with CTRL+C, but made no effort on implementing it into our library (it doesn't seem to be part of our responsibility). I will update the code snippets to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Left on comment.
Resolves #11, resolves #21
Adds new option
flushIntervalMs
forLogtailHandler
which ensures that logs are sent at least every X (every 5 seconds by default). This assumes that logs are created somewhat regularly.In default configuration, long running script would eventually run out of memory. For this reason, I've changed default
bufferLimit
to 1000 and changed default behavior from dropping logs to flushing logs on overflow. Also introducedthrowExceptions
option to control whether we should throwRuntimeException
on curl failure, which is by default false now to prevent apps from crashing.Since we have a bit too many parameters at this point, I've created a builder for comfortable handler creation (all methods will be suggested by IDE, all options named nicely). As an example, see comparison of suggested config from #21: