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

PSR-3 compliant logger #371

Open
jaimeperez opened this Issue Apr 21, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@jaimeperez
Member

jaimeperez commented Apr 21, 2016

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 $context parameter to all the methods defined by Psr\Log\LoggerInterface.
  • Make the \SimpleSAML\Logger::log() method public and make it throw a \Psr\Log\InvalidArgumentException if the log level is unknown.
  • Extract the log levels definition from \SimpleSAML\Logger and use the ones defined by Psr\Log\LogLevel instead.
  • Change the formatting that we have today. This means going from %option to {option}. We also need to think how to handle dates, since those have sub-formats using the strftime() 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\LoggerAwareInterface interface. That is, adding a setLogger() method, and using the internal logger object to log the messages.
  • Make all the logging methods defined in Psr\Log\LoggerInterface non-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 static getInstance() method to retrieve a logger that can be passed to setLogger(). 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\Logger class extend Psr\Log\AbstractLogger.
  • Exceptions should also be logger-aware, and pass themselves to the logger object when logging something in the context.

@jaimeperez jaimeperez added this to the 1.15.0 milestone Apr 21, 2016

@jaimeperez

This comment has been minimized.

Member

jaimeperez commented Apr 21, 2016

The new logging interface should be ready for 1.15, so that we can deprecate the old static methods and remove them for 2.0.

@jaimeperez jaimeperez modified the milestones: v2.0, 1.15.0 Jul 18, 2017

@tvdijen

This comment has been minimized.

Member

tvdijen commented Dec 11, 2018

@jaimeperez am I right that none of the tasks have been completed?

@jaimeperez

This comment has been minimized.

Member

jaimeperez commented Dec 12, 2018

I don't think we've done any work on this, no 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment