Commit Graph

8 Commits

Author SHA1 Message Date
Andreas Gohr 0ecde6ce23 central logging mechanism
This introduces a logger mechanism and a new data/log directory. This is
a first proof of concept. It's built on top of the new global error
handling mechanism

Things to discuss:

* should we adopt PSR-3 somehow? if yes, how and should plugins be able
  to drop-in other psr3 loggers?
* how to configure which facilities shall be logged?
* should we implement a log deletion feature?
* is the log format sensible?
* should we implement a log viewer admin plugin?
* should logging trigger events (it should maybe replace the
  deprecation event)
2020-08-13 13:28:40 +02:00
Andreas Gohr 51c1fbb36b no need to convert Errors to Exceptions
we handle Throwables anyway
2020-08-12 17:42:26 +02:00
Andreas Gohr dbe0790d4c FatalException and proper plugin detection
Using our own Exception makes it easier to differentiate fatal errors
from others in the log
2020-08-12 17:42:26 +02:00
Andreas Gohr cb4cefebb3 add shutdown handler to even manage fatal errors
We can't catch some errors and they are not passed to the error_handler
either. But we can at least react to them in a shutdown function to show
a friendly message to the user and write our log.
2020-08-12 17:42:26 +02:00
Andreas Gohr ffa84f8121 better exception handling on plugin loading
Now all important places where plugins are loaded are guarded by a
try/except. We're catching Throwables here to be able to catch stuff
like syntax errors early on (otherwise they will only be caught by our
ErrorConverter much too late). This means that this change requires PHP
7.0 minimum!
2020-08-12 17:42:26 +02:00
Andreas Gohr 0e69c9aff9 log stacktrace to error log
Ultimately the one responsible for fixing the problem will need this
anyway. Better log it right away for (hopefully) better bug reports
2020-08-12 17:42:26 +02:00
Andreas Gohr 7e0b27f2ad guess which plugin was the source of an exception
This looks at filenames and classes involved in the stacktrace to see if
a plugin is referenced.

We're only guessing plugins here, because looking for templates may
cause false positives where templates load plugins.
2020-08-12 17:42:26 +02:00
Andreas Gohr 642e976cb6 introduce a global error handler
This transfers old style PHP errors into Exceptions and installs a
global exception handler. All exceptions caught by this handler are
logged to an error log and a meassage is shown to the end user. This
should finally get rid of "blank page" bug reports.
2020-08-12 17:42:26 +02:00