VentureFree
Well-known member
- Joined
- Jan 9, 2008
- Messages
- 54
- Programming Experience
- 5-10
About a year ago I threw together a quick and dirty logging system for my class library (it's a dll) using the Observer pattern. Essentially the entire library shares an Observable class through which all messages are sent. Any code using this library can create an observer and subscribe to that class to see any and all messages being sent through the library (errors, warnings, information, and even progress tracking messages). The observer then does whatever it needs to do (save the messages to a file, print the messages to the screen, etc...).
I've never had to use more than a single observer (one for the program using the dll) so I'm wondering if the Observer pattern is really the way to go. I'm about to start work on a new library, and I want to build a good logger into it from the beginning.
So is there a better method for logging than sending everything through a single observable class?
I've never had to use more than a single observer (one for the program using the dll) so I'm wondering if the Observer pattern is really the way to go. I'm about to start work on a new library, and I want to build a good logger into it from the beginning.
So is there a better method for logging than sending everything through a single observable class?