1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-07-29 09:20:12 +02:00

55 Commits

Author SHA1 Message Date
Jordi Boggiano
c8b1e0e789 Fix serialization implementation 2023-02-06 14:43:38 +01:00
Jordi Boggiano
2ae044482c Fix serializability of Logger class, fixes #1792 2023-02-06 14:33:41 +01:00
Niklas Keller
0f014206a4 Fix cycle detection within fibers (#1753)
* Fix cycle detection within fibers

We keep a separate depth count per fiber.

Fixes #1752.

* Avoid additional call to Fiber::getCurrent()

Suppresses phpstan errors, as they're false positives.
2023-02-04 15:49:17 +01:00
Lusso Luca
ffd505543c Add RFC 5424 level (7 to 0) support to Logger::log and Logger::addRecord, fixes #1686 (#1723)
Co-authored-by: Jordi Boggiano <j.boggiano@seld.be>
2022-07-22 16:46:43 +02:00
henning
24e414c993 Added $datetime parameter to addRecord method to optionally log into the past/future 2022-06-09 10:49:31 +02:00
Jordi Boggiano
a5d65f6ec4 Fix infinite loops when a log handler triggers logging itself 2022-05-10 11:10:07 +02:00
Victor Pryazhnikov
cdba0c5693 Deprecated setMethods() usages moving to onlyMethods() 2021-02-27 14:47:59 +03:00
Mario Blažek
d317cb97d3 Move expectException before the line where exception is thrown 2019-08-13 15:34:48 +02:00
Mario Blažek
37900f9268 Upgrade PHPUnit to v8 2019-08-12 15:20:00 +02:00
George Mponos
e855ad8923 Remove not needed checks for PHP version 2018-12-11 17:01:05 +02:00
Jordi Boggiano
0ad73a526f CS fixes 2018-12-08 18:16:32 +01:00
Jordi Boggiano
204744df2e Merge branch '1.x' 2018-11-30 08:44:17 +01:00
Jordi Boggiano
a335f6f1a5 Fix tests for TestHandler reset support 2018-11-30 08:43:17 +01:00
Jordi Boggiano
073c5d763a Merge branch '1.x' 2018-11-04 18:40:32 +01:00
Grégoire Pineau
0625068bf0 Added a new ResettableInterface and implemented it where possible.
When one use Monolog in a long process like an AMQP worker with a
`FingersCrossedHandler` or `BufferHandler` there is a drawback: as soon as there
is an AMQP message that generate a log >= error (for example), all next AMQP
messages will output logs, even if theses messages don't generate log where
level >= error.

In the same context there is a drawback for processor that add an UUID to the
logs. The UUID should change for each AMQP messages.

---

This patch address this issue with a new interface: `ResettableInterface` interface.
Side note: `reset()`, `flush()`, `clear()`,  are already used in Monolog. So
basically, one can use the `reset()` on the `Logger` and on some
`Handler`s / `Processor`s.

It's especially useful for

* the `FingersCrossedHandler`: it `close()` the buffer, then it `clear()` the buffer.
* the `BufferHandler`: it `flush()` the buffer, then it `clear()` the buffer.
* the `UidProcessor`: it renew the `uid`.
2018-07-06 16:07:13 +02:00
Jordi Boggiano
12c9f58de2 Merge branch '1.x' 2018-06-08 21:08:04 +02:00
Vincent Paré
207c91699e Custom exception handler (#500)
Add custom exception handler to let the user change the default
behavior when Monolog raise an exception while logging a record.
2017-07-14 12:18:44 +02:00
Jordi Boggiano
ca4ffa68f6 Use namespaced phpunit classes, fixes #983 2017-06-19 00:48:54 +02:00
Sam-Burns
fa5d07f86f Skipping DateTime microsecond test in PHP 7.1.3, because of https://bugs.php.net/bug.php?id=74258 2017-04-01 21:52:18 +01:00
Jordi Boggiano
8f47e12463 Fix PHP7.1 DateTime support 2016-11-17 11:25:45 +01:00
Jordi Boggiano
4a43d9b17c Fix microseconds support on 7.1, and enable it by default as 7.1 has no perf cost anymore 2016-11-14 11:53:15 +01:00
Jordi Boggiano
5ce1c921ad Fix type errors, thanks phan 2016-09-25 22:11:37 +02:00
Jordi Boggiano
c6a9f28e24 Fix a ton of tests for latest phpunit and turn faked-stream tests into real network tests with a local server 2016-09-19 18:20:42 +02:00
Jordi Boggiano
89683faff3 Fixes microsecond timezone support, fixes #832 2016-09-19 13:24:54 +02:00
Jordi Boggiano
21dde4dedb Move to strict mode and fix tests 2016-05-27 13:44:00 +01:00
Jordi Boggiano
f200e79879 CS fixes 2016-05-26 20:54:06 +01:00
Jordi Boggiano
ba995ffd1e Merge branch '1.x' 2016-03-01 17:15:43 +00:00
Jordi Boggiano
cb2778ae77 Add ->withName to clone a handler and get a new name, fixes #730 2016-02-13 16:47:31 +00:00
Jordi Boggiano
6c424f851c Add a lot more scalar types and go strict in Logger 2015-12-18 17:48:48 +00:00
Jordi Boggiano
39f8a20e6d Remove non-PSR-3 methods for adding log records 2015-12-18 17:48:38 +00:00
Jordi Boggiano
6505e02fd3 Change timezone to be per-instance and not global 2015-12-18 17:48:36 +00:00
Jordi Boggiano
cab3ff71ff Add regression test for #691 and optimize implementation using a single pass loop over the handlers, refs #692 2015-11-26 23:48:42 +00:00
Jordi Boggiano
c889fb2648 CS fixes & upgrading cs fixer config 2015-11-18 17:09:46 +00:00
Bryan Davis
4e69837afc Optionally reduce timestamp resolution for performance
Introduce a new `useMicrosecondTimestamps()` method to Logger that
allows runtime selection of whether or not to create microsecond
resolution timestamps for log records.

Generating microsecond resolution timestamps by calling
`microtime(true)`, formatting the result via `sprintf()` and then
parsing the resulting string via `DateTime::createFromFormat` can incur
a measurable runtime overhead vs simple usage of `new DateTime` to
capture a second resolution timestamp in systems which generate a large
number of log events.

The default behavior of generating high precision timestamps remains the
same, but may be changed in a future release. Users requiring high
precision timestamps are encouraged to explicitly call
`Monolog\Logger::useMicrosecondTimestamps(true)` in their setup code.

Closes #657
2015-10-25 15:13:43 -06:00
Jordi Boggiano
419ca7ac25 Tweak patch a bit, refs #617 2015-08-09 18:28:21 +01:00
Sam Minnee
60c96cfa2a Added Logger::setHandlers()
Logger::setHandlers() is intended to help dependency injection systems
that deal more elegantly with property setters than constructor
arguments. Alongside getHandlers(), pushHandler(), popHandler(), it is
a logical addition to the API.

It also attempts to address some possible errors in the format of the
data passed:

 - If a map is passed, the keys are removed, as these aren’t expected
   by Monolog
 - If falsey values are included, these are stripped

It relies on Logger::pushHandler() internally, so that if any special
behaviour is added in the future, this only needs to be added in one
place.
2015-07-28 13:15:02 +12:00
Jordi Boggiano
8c4b1be4a2 Change Logger::setTimezone to accept a DateTimeZone object, refs #566 2015-06-01 21:15:07 +01:00
Bryan Davis
5d7db08106 Add Logger::setTimezone()
Add a setter method to allow changing the timezone used when creating
new log records. This provides a means to correct a behavioral change
introduced by 6cbdc04 where use of the PHP runtime default timezone
provided by `date_default_timezone_get()` was introduced. In most
environments the new default behavior is preferable, but if an
application allows the default timezone to vary between requests it
causes confusing log output.
2015-05-20 22:05:03 -06:00
Reda Bouchaala
2cb4a57490 Removed Logger::toMonologLevel() code duplication and added relevant tests 2015-04-25 19:42:19 +01:00
Jordi Boggiano
392ef35fd4 CS fixes 2014-03-23 20:50:26 +01:00
Jordi Boggiano
9f515d47ce Add possibility to pass handlers/processors to Logger::__construct, fixes #157 2013-02-13 19:06:07 +01:00
Jordi Boggiano
9c8db38385 CS fixes 2012-12-14 12:15:30 +01:00
Jordi Boggiano
b23cfd3d6c Throw an exception on invalid level name 2012-11-14 16:46:10 +01:00
Jordi Boggiano
61359a972b Merge remote-tracking branch 'FGM/master' 2012-06-19 20:28:04 +02:00
Jordi Boggiano
da33c84d07 CS fixes 2012-06-14 15:47:01 +02:00
Frederic G. MARAND
07aac12c72 Implement the 8 RFC3164 severity levels instead of just 6.
- constants defined for the 2 missing levels: NOTICE and EMERGENCY.
- add<level>() and <level>() convenience methods added.
- TestHandler and tests updated to account for the two extra levels.
- surjective mappings from the RFC3164 to only 6 levels changes to bijective.
- README updated accordingly.
2012-05-28 20:29:27 +02:00
Jordi Boggiano
355123d607 Add isHandling, fixes #53 2012-01-28 14:43:55 +01:00
Christophe Coevoet
64009a5880 Added more tests for the logger 2011-09-06 23:37:29 +02:00
Christophe Coevoet
10e5ecd409 Added some tests 2011-08-29 15:00:28 +02:00
Artem Nezvigin
f31388ec42 Added logger name getter, Monolog\Logger::getName()
Added phpunit.xml to .gitignore to prevent contributors from accidentally commiting theirs.
2011-08-07 16:29:10 -07:00