1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-24 18:16:10 +02:00
Commit Graph

88 Commits

Author SHA1 Message Date
Alexander M. Turek
2e37d0bbd1 Fix deprecation warning on PHP 8.1 2021-05-15 01:18:18 +02:00
Jordi Boggiano
279cf6a900 Migrate to GH actions, add phpstan 2020-12-09 13:49:22 +01:00
Matthias Pigulla
f8245696b3 Use strtr() instead of strtoupper() to avoid bogus results
For examle the tr_TR locale will upper-case "i" to the
"latin capital letter i with dot above" İ.
2019-12-07 11:40:26 +00:00
Jordi Boggiano
b80352368c Add Logger::close and clarify what close and reset do plus 2018-11-04 22:15:25 +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
120c434db9 Verify handlers types, fixes #1131 2018-06-11 17:30:42 +02:00
Jordi Boggiano
6d79e51f91 Tweaks to exception handler, refs #1012 2018-06-08 21:02:44 +02:00
Jordi Boggiano
4814446331 Merge remote-tracking branch 'vincepare/1.x' into 1.x 2018-06-08 20:44:28 +02:00
Jordi Boggiano
8c4539f1fe More boolean=>bool 2018-06-07 18:45:07 +02:00
Erik Booij
ecdfdc9897 Rename Boolean in phpDocs to bool 2017-11-04 12:14:41 +01: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
8f47e12463 Fix PHP7.1 DateTime support 2016-11-17 11:25:45 +01: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
Robbie Averill
ea2bef43a9 DRY: Use constants for level codes instead of re-defining 2015-12-16 09:34:12 +13: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
Matt Johnson
73876ace65 Changed iterating over the $handlers array to allow for correct sequential processing regardless of array containing indexed numerical keys, or associative string keys in the array.
It iterates over the entire array until it finds the $handlerKey that was identified earlier using isHandling(). Once the starting position is found it will execute handle() on each handler unless a handler returns true indicating the handler completed the processing of the record, bubbling to the next handler should not occur, and the loop breaks.

This fixes an issue where an associative array of handlers is passed into the Logger constructor when instantiated.
magento/magento2#2529
Seldaek/monolog#691
2015-11-26 02:33:02 -06: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
ca1376bd61 CS fixes 2015-07-14 10:26:05 +01: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
Ron Kirschler
657989dd22 Added self-referenced returns to get fluent interfaces for Monolog\Logger::pushProcessor and Monolog\Logger::pushHandler
For more information, look at the [comment in this file](8cb4d9237c/docs/index.md (combine-with-monolog)).
2015-05-07 21:39:48 +02:00
Reda Bouchaala
2cb4a57490 Removed Logger::toMonologLevel() code duplication and added relevant tests 2015-04-25 19:42:19 +01:00
tiagowbpr
59c52eeea5 Php docs small error 2014-12-05 23:46:37 -02:00
Jordi Boggiano
673e275c00 Update comments 2014-12-04 15:11:17 +00:00
Edson Medina
ae68665460 getLevelName needs to be called earlier, so it can still thrown
exceptions for invalid levels even without a handler
2014-12-02 23:51:28 +00:00
Edson Medina
38f8dc52de Avoid calling expensive methods before checking we need to 2014-12-02 22:07:18 +00:00
Jordi Boggiano
feb19af2d4 Add support for PSR-3 levels to all public APIs accepting levels, fixes #421 2014-09-30 13:59:45 +01:00
Jordi Boggiano
467e30a9c9 Add getters for handlers/processors, fixes #363 2014-05-01 17:55:56 +02:00
Jordi Boggiano
97f79f7ed3 Fix docblock, fixes #358 2014-04-21 20:22:17 +02:00
Michael Grinko
fab4ec2c12 [minor] Indent was fixed 2014-01-15 11:01:53 +02:00
Jordi Boggiano
3926d95f8a CS fixes 2013-12-26 11:43:12 +01:00
Markus Staab
100a1b01f2 Minor phpdoc fixes 2013-12-26 00:25:22 +01:00
Peter Kokot
97043a326c logging levels phpdoc added 2013-09-21 23:43:29 +02:00
Jordi Boggiano
e2b412846d Add API version to Logger class 2013-05-21 20:36:09 +02:00
Jordi Boggiano
7e56792987 Fix docblock 2013-04-23 11:10:54 +02:00
Joshua Jabbour
6a8154756e Flip getLevels() response. 2013-04-15 12:24:24 -05:00
Joshua Jabbour
85dbaf9733 Add getter to return all supported log levels. 2013-04-15 11:46:35 -05:00
Eduardo Oliveira
f84f58188c At isHandling remove unused variable on foreach 2013-03-24 12:11:22 +00:00
Jordi Boggiano
9f515d47ce Add possibility to pass handlers/processors to Logger::__construct, fixes #157 2013-02-13 19:06:07 +01:00
Florin Patan
5191ce91a1 Deferred timezone creation 2013-02-10 12:07:16 +02:00
Jordi Boggiano
7913cd2c4d Add psr/log compatibility 2013-01-04 17:20:27 +01:00
Jordi Boggiano
cb83512ca5 Make isHandling create the minimum required record 2012-12-21 09:41:30 +01:00
Jordi Boggiano
b23cfd3d6c Throw an exception on invalid level name 2012-11-14 16:46:10 +01:00
Thomas Rabaix
5e0fabeb0d Add the timezone in the the \DateTime constructor. While the DateTime object
is initialized without the DateTimeZone instance, the underline library
execute a stat('.../Europe/Paris') to check if the OS knows the timezone.

This will improve performance on long run process by avoiding unless i/o calls.
2012-10-24 14:58:02 +02:00
Aizat Faiz
938b608c6c Use late static binding to allow people to extend Logger 2012-10-19 08:12:34 -07:00
Jimmy Berry
48729c02c8 Correct handler comment. 2012-09-07 23:06:35 -07:00
Jordi Boggiano
6cbdc0410c Set default timezone on log records, fixes #94 2012-06-26 14:56:24 +02:00