tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/11218-selective-loggingRobotlegs: Discussion 2014-07-02T07:20:35Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/333983682014-06-14T04:48:27Z2014-06-14T04:48:27ZSelective Logging<div><p>logger.logLevel = LogLevel.Error</p>
<p>Inject logger in your configuration for good placement :)</p>
<p>S poštovanjem,<br>
Matej Šimunić</p></div>matejtag:robotlegs.tenderapp.com,2009-10-18:Comment/333983682014-06-15T01:42:06Z2014-06-15T01:42:06ZSelective Logging<div><p>Thanks but I have a mix of debug and info statements i want to
disable for<br>
a specific class yet still see info and debug from others. I was
hoping to<br>
do this from a command at runtime. Classes already have a
logger<br>
instance... maybe I just need a more powerful log file analyzer
that can<br>
filter those classes out.... Thought I might be able to check where
the log<br>
statements are sent and skip if they match a list of classes.</p></div>dantag:robotlegs.tenderapp.com,2009-10-18:Comment/333983682014-06-19T21:46:42Z2014-06-19T21:52:38ZSelective Logging<div><p>Had some time to figure this out, here's what I did if someone
else finds it useful. This only works if you grab loggers with your
class type.</p>
<p>So to mute a class at runtime, just do the following:</p>
<p><code>TraceLogTarget2.mute( ClassName )</code></p>
<p>It'd be nice to disable an entire package but haven't had time
for that yet.</p>
<pre>
<code>class TraceLogTarget2 extends TraceLogTarget
{
private static var muteMap:Object = {};
public static function mute(source:Object):void
{
muteMap[source] = 1;
}
public static function unmute(source:Object):void
{
muteMap[source] = 0;
}
public static function unmuteAll():void
{
muteMap = {};
}
override public function log(source:Object, level:uint, timestamp:int, message:String, params:Array=null):void
{
// skip log if object has been muted
if( !muteMap.hasOwnProperty( source ) || muteMap[source] == 0 )
super.log( source, level, timestamp, message, params );
}
}</code>
</pre></div>dantag:robotlegs.tenderapp.com,2009-10-18:Comment/333983682014-06-20T06:25:26Z2014-06-20T06:25:26ZSelective Logging<div><p>Cool! Thanks for sharing your solution with us.</p></div>Ondina D.F.