<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>foomonger&#039;s blog &#187; logging</title>
	<atom:link href="http://blog.foomonger.com/tag/logging/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.foomonger.com</link>
	<description>Tips and Musings on Software Development, Flash, and Flex</description>
	<lastBuildDate>Wed, 05 Jan 2011 18:08:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SwizLogger Helpers: SwizLoggerConfig and LoggerProcessor</title>
		<link>http://blog.foomonger.com/2010/03/20/swizlogger-helpers-swizloggerconfig-and-loggerprocessor/</link>
		<comments>http://blog.foomonger.com/2010/03/20/swizlogger-helpers-swizloggerconfig-and-loggerprocessor/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 23:46:56 +0000</pubDate>
		<dc:creator>Sam Ahn</dc:creator>
				<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[custom processor]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[swiz]]></category>

		<guid isPermaLink="false">http://blog.foomonger.com/?p=142</guid>
		<description><![CDATA[I started using the SwizLogger recently and quickly realized I wanted to do the following:

Create ILogger instances without importing Swiz classes in my application classes
Easily add targets in MXML

#1 isn't a huge deal if you consider logging to be more of a system tool than an application dependency, but if I'm avoiding Singletons why not [...]]]></description>
			<content:encoded><![CDATA[<p>I started using the SwizLogger recently and quickly realized I wanted to do the following:</p>
<ol>
<li>Create ILogger instances without importing Swiz classes in my application classes</li>
<li>Easily add targets in MXML</li>
</ol>
<p>#1 isn't a huge deal if you consider logging to be more of a system tool than an application dependency, but if I'm avoiding Singletons why not keep it up. #2 also isn't a big deal because it doesn't take much ActionScript to add logging targets, but I think it makes a lot of sense to do it declaratively.</p>
<p>Piotr Walczyszyn created a <a title="LogProcessor" href="http://www.riaspace.net/2009/12/logprocessor-custom-metadata-processor-for-swiz-1-0-0/" target="_blank">custom LogProcessor</a> to address #1, but I didn't like how the TraceTarget was hard-coded into it. Instead of building more complex processor I decided to create a bare-bones <a title="LoggerProcessor" href="http://code.google.com/p/foomonger-swizframework/source/browse/trunk/FoomongerSwizFramework/src/com/foomonger/swizframework/processors/LoggerProcessor.as" target="_blank">LoggerProcessor</a> and <a title="SwizLoggerConfig" href="http://code.google.com/p/foomonger-swizframework/source/browse/trunk/FoomongerSwizFramework/src/com/foomonger/swizframework/utils/SwizLoggerConfig.as" target="_blank">SwizLoggerConfig</a> class.</p>
<p>Here's an example application's source (the SWF is just a button):  <a title="SwizLoggerConfigExample" href="http://www.foomonger.com/swizframework/SwizLoggerConfigExample/srcview/" target="_blank">Source</a></p>
<p>The LoggerProcessor is again bare-bones. All it does is inject an ILogger instance using SwizLogger:</p>
<pre class="actionscript"><span style="color: #66cc66;">&#91;</span>Logger<span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> logger:ILogger;</pre>
<p><br/><br />
The LoggerProcessor priority is set to be one above [Inject] so the injected ILoggers are available at [Inject] and [PostConstruct].</p>
<p>SwizLoggerConfig doesn't do too much either. It's just provides a default public Array property which is used to add targets to the SwizLogger.</p>
<pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="font-weight: bold; color: black;">?&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx:Application</span> <span style="color: #000066;">xmlns:mx</span>=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span>
        <span style="color: #000066;">xmlns:utils</span>=<span style="color: #ff0000;">&quot;com.foomonger.swizframework.utils.*&quot;</span>
        <span style="color: #000066;">xmlns:view</span>=<span style="color: #ff0000;">&quot;example.view.*&quot;</span>
        <span style="color: #000066;">xmlns:local</span>=<span style="color: #ff0000;">&quot;*&quot;</span>
        <span style="color: #000066;">layout</span>=<span style="color: #ff0000;">&quot;absolute&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx:Script<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #339933;">&lt;![CDATA[</span>
<span style="color: #339933;">            import mx.logging.LogEventLevel;</span>
<span style="color: #339933;">        ]]&gt;</span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/mx:Script<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;utils:SwizLoggerConfig<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx:TraceTarget</span>
                <span style="color: #000066;">includeCategory</span>=<span style="color: #ff0000;">&quot;true&quot;</span>
                <span style="color: #000066;">includeDate</span>=<span style="color: #ff0000;">&quot;false&quot;</span>
                <span style="color: #000066;">includeLevel</span>=<span style="color: #ff0000;">&quot;true&quot;</span>
                <span style="color: #000066;">includeTime</span>=<span style="color: #ff0000;">&quot;true&quot;</span>
                <span style="color: #000066;">level</span>=<span style="color: #ff0000;">&quot;{LogEventLevel.INFO}&quot;</span>
                <span style="color: #000066;">filters</span>=<span style="color: #ff0000;">&quot;*&quot;</span>
                <span style="color: #000066;">fieldSeparator</span>=<span style="color: #ff0000;">&quot; | &quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/utils:SwizLoggerConfig<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;local:SwizLoggerConfigExampleSwiz</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;view:MainView</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/mx:Application<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<p><br/></p>
<p>The value of these classes will depend on your personal style and preference. I wrote them so I like them. They're available on <a href="http://code.google.com/p/foomonger-swizframework/" target="_blank">Google Code</a>.</p>
<p>Happy coding.</p>
<p><br/><br />
* Update: Here's the MXML syntax for adding multiple packages to the filters Array:</p>
<pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx:TraceTarget</span>
        <span style="color: #000066;">includeCategory</span>=<span style="color: #ff0000;">&quot;true&quot;</span>
        <span style="color: #000066;">includeDate</span>=<span style="color: #ff0000;">&quot;false&quot;</span>
        <span style="color: #000066;">includeLevel</span>=<span style="color: #ff0000;">&quot;true&quot;</span>
        <span style="color: #000066;">includeTime</span>=<span style="color: #ff0000;">&quot;true&quot;</span>
        <span style="color: #000066;">level</span>=<span style="color: #ff0000;">&quot;{LogEventLevel.INFO}&quot;</span>
        <span style="color: #000066;">fieldSeparator</span>=<span style="color: #ff0000;">&quot; | &quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx:filters<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        [&quot;foo.bar.*&quot;, &quot;com.foomonger.*&quot;]
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/mx:filters<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/mx:TraceTarget<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.foomonger.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.foomonger.com/2010/03/20/swizlogger-helpers-swizloggerconfig-and-loggerprocessor/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

