-
Notifications
You must be signed in to change notification settings - Fork 698
Better handling of multi-line logs (e.g., with backtrace) #311
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
base: master
Are you sure you want to change the base?
Conversation
…ing code. Introduces option for 'json' log format, in which case syslog will json_encode() the log contents. Also demotes the message logging the error ID to a notice.
eaef53a to
4bd3fa1
Compare
|
Thanks for the PR @bradjones1! Could you provide some example outputs for both the default, backwards-compatible logging, and the new format with JSON? |
|
Hi again @bradjones1! I've recently enhanced a bit the handling of logs, including those with backtraces. Backtraces are now logged as debug, so they can be ignored easily if you want. Regarding the formatting in JSON, wouldn't that be possible if you provide a JSON-encoded string in the |
1c686ab to
eb20457
Compare
08ebb9c to
64fca25
Compare
7a53fc8 to
d73ae47
Compare
e5c0e21 to
d5616df
Compare
2e6ab04 to
32f9acc
Compare
7e3ea19 to
2523634
Compare
3b5f5ba to
96357ee
Compare
7587851 to
d523b31
Compare
8c90121 to
d534e3b
Compare
bc1c5c8 to
d0a5974
Compare
ccb9b02 to
120a100
Compare
6004a77 to
58bf8db
Compare
5c9fb2c to
0970efc
Compare
c27831c to
71e49f4
Compare
c06a17a to
a52c98d
Compare
Hopefully this PR isn't too broad, but I've attempted to clean up some of the logging logic particularly when it comes to handling multi-line messages. Reading through the existing code, most messages destined for the log appear as $string, and a string is assumed, though the Logger's log() function includes an implode() if it's indeed passed an array.
I ship my logs off to an offsite log aggregation service, using rsyslog as an intermediary. Furthermore I like to package log messages as JSON, either in the application or with an rsyslog template. This PR is backwards-compatible with existing configurations but will result in only one "main" error message being logged, as opposed to the foreach() that was running which resulted in one log message per line. That can become a bit unwieldy with the backtrace.
If the logging service is syslog and the format is set to "json," the message is maintained as an array and is then JSON-encoded.
Also this downgrades the "Error report generated" message to a notice, since it is not itself the error, but simply a note about the logged error.
Includes some abstraction in Exception.php as the result of the removal of those foreach() loops.