So an initial design (to meet the specified requirements) might be as
follows:
Three classes:
1) A Log Factory (Singleton)
2) A Log Manager (Singleton)
3) A hierarchy of loggers
The factory will access an *.ini file and create the required log
objects (obviously it doesn't need to be just a ini file but let's
initially stick with that)
The manager will receive a log request and send the message to the
appropriate log objects
The log object will do the actual logging
The *.ini file will need to perform the following:
1) Define logging priorities (there may be some system defined
priorities but this will also allow for some user defined priorities)
2) List the loggers required
a) name (used within the *.ini)
b) class
c) constructor parameters (such as destination and extra data
required)
3) Map priorities to loggers
From the programmers perspective there would be two ways to log either
statically Log::msg($logmsg, $priority); or through an object
getContext()->getLogger()->msg($logmsg, $priority); These would both
send the log message to the manager who would then determine which of
the logger objects would require to receive the message.
Do we want to support a third access method?
getContext()->getLogger($logName)->msg($logmsg); Which would bypass the
manager and send the message to a selected logger object?
How should logging be used within the frame work? I would certainly
advocate changing Exceptions to use the logging mechanism, that way
displaying it on the screen can be turned off when it goes into
production but any exceptions can still be logged.
graeme.
Mike Vincent wrote:
Immediately, I would like to...
* Write every message to a file, noting the priority I valued the
message with when logged
* If in a specific module, also log the message to a table in the db
pulling in other factors such as the id of the user and some
parameters present in the request object at the time of the event,
perhaps even some attributes of the user object as well.
* If the message is of a specific priority, Email it to a configured
address (could also be SMS, IM, etc..)
Somethings we havent really discussed (in this thread) are:
* How, if at all, the logging will be utilized internally within the framework?
* Use logging to push feedback messages to the user on the page?
Some of us discussed the feedback case and I think we each came to the
consensus that it was a different animal, but I throw it out there
anyway.
Some more to nibble on..
-Mike
_______________________________________________
agavi-dev mailing list
[email protected]
http://labworkz.com/cgi-bin/mailman/listinfo/agavi-dev
_______________________________________________
agavi-dev mailing list
[email protected]
http://labworkz.com/cgi-bin/mailman/listinfo/agavi-dev