Implement the observer pattern so that loggers can be added #3

Closed
cpliakas opened this Issue Mar 11, 2012 · 5 comments

2 participants

@cpliakas
Owner

Pluggable logging functionalities that wrap around systems such as Zend_Log or Drupal's watchdog should be implemented by this library to capture errors and debugging information.

UPDATE: Implementing the observer pattern should work fine without explicitly adding the loggers.

@ebeyrent

Perhaps make use of the Observer pattern and have the Parser implement SplSubject?

@cpliakas
Owner

My first reaction is that this seems like a perfect use case for the observer pattern. The SplObserver class would be a good abstraction for any framework's logger. The way I see this working is that the parser would have to implement some method to get the last error or message. Maybe something like a setMessage($message, $severity) method, and then the observer can call the getMessage() and getSeverity() classes? Thoughts?

@cpliakas
Owner

Created the "logging" branch for this at https://github.com/cpliakas/Nagiostatus/tree/logging.

@ebeyrent

That'll work for most simple cases - you may consider having addMessage() instead which adds the message to an array, and then have getLastMessage() return the last element of that array. One use case is that a number of successful status messages could be set representing a chain of steps, which is very useful for debugging when things go wrong. You could also have the notion of getLastError() that would return the latest message of a certain severity.

@cpliakas
Owner

I added the observer pattern implementation to the logging branch. master...logging

@cpliakas cpliakas added a commit that closed this issue Mar 26, 2012
@cpliakas fixed #3: Implemented observer pattern which will provide the ability…
… for third party loggers.
3cdddd6
@cpliakas cpliakas closed this in 3cdddd6 Mar 26, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment