Comments (5)
I would try setting the file manually via:
Analog::handler (\Analog\Handler\File::init ('my_log_file.txt'));
The lock is in place since concurrent requests may try to write to the file at the same time. It's strange that the lock gives you trouble on travis-ci since that's never given me an issue on there...
https://travis-ci.org/jbroadway/analog/builds
If that doesn't do it, you can always create a custom handler based on the File handler that removes the locking.
from analog.
When there are two many requests to access the same file, it throws a lock error because LOCK_NB is specified in line 26 of analog/lib/Analog/Handler/File.php. Remove that like below and it should block while trying to lock the file.
if (! flock ($f, LOCK_EX)) {
throw new \RuntimeException ('Could not lock file');
}
from analog.
@jbroadway I'm already using the code you give to init the file handler, excepting it is part of a multi handler, using something like this:
$run_log = \Analog\Handler\File::init($log_path);
$null_log = \Analog\Handler\Null::init();
Analog::handler(
\Analog\Handler\Multi::init(
array (
Analog::URGENT => $run_log,
Analog::ALERT => $run_log,
Analog::CRITICAL => $run_log,
Analog::ERROR => $run_log,
Analog::WARNING => $null_log,
Analog::NOTICE => $null_log,
Analog::INFO => $null_log,
Analog::DEBUG => $null_log
)
)
);
@mta59066 thank you for the pointer :) I guess I should use that in a custom handler based on File one.
I guess I should also disable logging for my unit tests; logging is much more useful for the users who do not have access to syslogs in production environments.
In "normal" conditions, I should not have so many requests to the logger in a few seconds; and I never ran into that issue; running the test that did not happen every time anyway :/
I'll double check my logs call to see if one of them is not called "too frequently".
Thank you :)
from analog.
Looking into LOCK_NB more closely, I believe @mta59066's suggestion to remove it should become the default case. The log file won't be locked for more than a few milliseconds, so blocking isn't really an issue, and we do want to ensure that messages do arrive as expected. Will fix it momentarily.
Thanks for exposing this issue! :)
from analog.
Great, thank you very much @jbroadway and @mta59066 :-)
from analog.
Related Issues (20)
- Add handler for Chrome Logger via ChromePHP
- Analog use gmdate HOT 7
- Issue when running in Strict standard mode PHP
- question: is it on purpose that the date is inserted as a string in MongoDB? HOT 2
- Null is reserved in PHP 7 HOT 2
- Class Mail. Request best config HOT 2
- Add handler to translate log levels to their names HOT 1
- Mix Multi and Threshold handlers HOT 3
- Send log to multiple separate handlers (mongo & slack)? HOT 1
- Cannot use 'Null' as class name as it is reserved HOT 2
- MariaDB/MySQL support HOT 1
- Composer can't find analog HOT 2
- Direct output HOT 2
- Output converted log level HOT 2
- how to use it without composer? HOT 3
- PHP Parse error on Echo handler
- Uncaught Error: Undefined class constant 'ATTR_ERRMODE' in analog/analog/lib/Analog/Handler/PDO.php:52 HOT 1
- Ignored context argument HOT 4
- Support OpenTelemetry protocol
- Support multiple logger instances out of the box HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from analog.