I really like the idea of moving more of the responsibility of logging to the logWriter bean. It opens up the ability to provide alternate implementations that meet the varying needs of different developers.
I'm particularly interested in a LogBox<http://wiki.coldbox.org/wiki/logbox.cfm>adapter for logWriter. I like the flexibility of the logging approach popularized by Log4j, and LogBox looks to be a very good ColdFusion implementation of that approach. With this flexibility, not only can the developer control what gets logged, but also where. LogBox comes with over a dozen appenders to send log messages to files, databases, emails, and even Twitter. Another feature that would go hand-in-hand with a LogBox adapter for logWriter is a ModelGlue appender for LogBox. This would allow LogBox to append messages to the current ModelGlue debug log. A ModelGlue appender would need the event context to work, which means the logWriter adapter would need to pass the event context through the extraInfo argument. The extraInfo argument can be any type, but it may be best to make it a struct and use a single key in it for the MG event context to allow other appenders to use extraInfo for other purposes. Maybe I'll go implement all this in my "Copious Spare Time"(tm) :-) Cheers, -- Dennis On Tue, Jan 19, 2010 at 7:46 AM, Dan Wilson <[email protected]> wrote: > The way the current SVN build works is this: > > 1) When addTraceStatement is called, the arguments are pushed into the > logWriter implementation. This happens regardless of the debug or reload > status. > > 2) The current implementation of logWriter does some checks to see whether > and how to log the passed data: > > <cffunction name="write" output="false"> > <cfargument name="eventContext" /> > <cfargument name="logMessage" /> > > <!--- > We want to log complex values when debug is set to verbose so > convert it to a simple value with dump. > > > > > > ---> > <cfif variables.debugMode IS "verbose" AND > isSimpleValue(arguments.logMessage.message) IS false > > <cfsavecontent variable="arguments.logMessage.message"><cfdump > var="#arguments.logMessage.message#" /></cfsavecontent> > > > > > > </cfif> > > <!--- > Log simple values when debug isn't disabled' > ---> > <cfif variables.debugMode IS NOT "none" AND > isSimpleValue(arguments.logMessage.message) IS true > > > > > > > <cfset arrayAppend(eventContext.log, arguments.logMessage) /> > </cfif> > > </cffunction> > > > So, this pushes responsibility down to the logWriter as to how to log items > or not. You could provide your own implementation of logWriter, and add it > to your ColdSpring.xml with the bean ID of modelGlue.logWriter and then have > custom logging as you please. > > The logWriter currently has the value of debug passed in at creation time. > The the logMessage argument of logWriter.write() has the EventContext along > with the original arguments to addTraceStatement: > So valid values are: logMessage.type, logMessage.message, logMessage.tag, > logMessage.traceType > > You could do any sort of processing you want based on those values. So, one > way to always log something, would be to use the type of AlwaysLog in your > addTraceStatement call, then look for that in your logWriter. > > > Thoughts? > > DW > >
-- Model-Glue Sites: Home Page: http://www.model-glue.com Documentation: http://docs.model-glue.com Bug Tracker: http://bugs.model-glue.com Blog: http://www.model-glue.com/blog You received this message because you are subscribed to the Google Groups "model-glue" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/model-glue?hl=en
