Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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

Closed
cpliakas opened this Issue · 5 comments

2 participants

Chris Pliakas Erich Beyrent
Chris Pliakas
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.

Erich Beyrent

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

Chris Pliakas
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?

Chris Pliakas
Owner

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

Erich Beyrent

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.

Chris Pliakas
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.