simplesamlphp / simplesamlphp/simplesamlphp
PSR-3 compliant logger
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.1k
- Forks
- 704
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 4
Description
We should make our logger PSR-3 compliant, and make all the classes logging something to use this. This is especially useful for unit testing because we could get rid of the static methods, and also for the SAML2 library, which could use our logger or some other instead.
In general, the steps would be:
- Add a
$contextparameter to all the methods defined byPsr\Log\LoggerInterface. - Make the
\SimpleSAML\Logger::log()method public and make it throw a\Psr\Log\InvalidArgumentExceptionif the log level is unknown. - Extract the log levels definition from
\SimpleSAML\Loggerand use the ones defined byPsr\Log\LogLevelinstead. - Change the formatting that we have today. This means going from
%optionto{option}. We also need to think how to handle dates, since those have sub-formats using thestrftime()date and time formatting rules. We would probably need to split the log format and the format for dates, and handle replacements manually. - Make all the classes logging something to implement the
Psr\Log\LoggerAwareInterfaceinterface. That is, adding asetLogger()method, and using the internal logger object to log the messages. - Make all the logging methods defined in
Psr\Log\LoggerInterfacenon-static (they are static today). This means we need to add a constructor for the Logger. A Singleton approach would probably be the way to go, with a staticgetInstance()method to retrieve a logger that can be passed tosetLogger(). This also cleans the logger initialization we have today, and would allow us to get rid of the logging handlers and have just loggers that extend the basic logging class. - Make the
\SimpleSAML\Loggerclass extendPsr\Log\AbstractLogger. - Exceptions should also be logger-aware, and pass themselves to the logger object when logging something in the context.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the PSR-3 LoggerInterface, LoggerAwareInterface, and the existing SimpleSAML\Logger entry points. Review the remaining checklist items, including format handling, non-static logging, logger-aware classes, and exceptions. Done means the unchecked compatibility and injection work is implemented consistently and covered by the project's tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend, developer-experience
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 20/100