<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Paraguay Groovy</title>
	<atom:link href="http://groovypy.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://groovypy.wordpress.com</link>
	<description>About Groovy and Java from Paraguay</description>
	<lastBuildDate>Mon, 05 Oct 2009 22:55:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='groovypy.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/22d42ff9bfcf95c9c27f0fdc5923e933?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Paraguay Groovy</title>
		<link>http://groovypy.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://groovypy.wordpress.com/osd.xml" title="Paraguay Groovy" />
	<atom:link rel='hub' href='http://groovypy.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Add a Security Log Level to Log4J groovily</title>
		<link>http://groovypy.wordpress.com/2009/10/03/add-a-security-log-level-to-log4j-groovily/</link>
		<comments>http://groovypy.wordpress.com/2009/10/03/add-a-security-log-level-to-log4j-groovily/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 04:14:07 +0000</pubDate>
		<dc:creator>groovypy</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[groovy]]></category>

		<guid isPermaLink="false">http://groovypy.wordpress.com/?p=28</guid>
		<description><![CDATA[In the las post I showed how to make logging available to all object instances. This post will add a few line to the former code to log security events. At least for my feelings somehow the creators of Log4J forgot to add a security level as one of the default log levels in Log4J. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=groovypy.wordpress.com&amp;blog=9670182&amp;post=28&amp;subd=groovypy&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In the las post I showed how to make logging available to all object instances. This post will add a few line to the former code to log security events.</p>
<p>At least for my feelings somehow the creators of Log4J forgot to add a security level as one of the default log levels in Log4J. It is easy to add a new log level to Log4J and whith Groovy it gets (as usual) even more easy. Let&#8217;s see how:</p>
<pre class="brush: plain;">
static {

    ...

    static final Level SECURITY = new Level(45000, &quot;SECURITY&quot;, 08)

    Object.metaClass.static.logSecurity = { Object msg, Throwable ex = null -&gt;
      delegate.logger.log(logger.FQCN, SECURITY, msg, ex)
    }
}
</pre>
<p>Now you can say http://groovypy.wordpress.com/wp-admin/post-new.php#edit_timestamp</p>
<p><code>logSecurity 'Insecure user detected'</code></p>
<p>in your code. If you think &#8216;SECURITY&#8217; should be added to the Level class you feel like me. Unfortunately Groovy does not allow this with its current metaobject protocol implementation. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/groovypy.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/groovypy.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/groovypy.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/groovypy.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/groovypy.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/groovypy.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/groovypy.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/groovypy.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/groovypy.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/groovypy.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/groovypy.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/groovypy.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/groovypy.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/groovypy.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=groovypy.wordpress.com&amp;blog=9670182&amp;post=28&amp;subd=groovypy&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://groovypy.wordpress.com/2009/10/03/add-a-security-log-level-to-log4j-groovily/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/320c8b9237cdd3282b14150829caf4cb?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">groovypy</media:title>
		</media:content>
	</item>
		<item>
		<title>Central Logging Configuration in Groovy</title>
		<link>http://groovypy.wordpress.com/2009/09/28/14/</link>
		<comments>http://groovypy.wordpress.com/2009/09/28/14/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 19:35:43 +0000</pubDate>
		<dc:creator>groovypy</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[groovy]]></category>

		<guid isPermaLink="false">http://groovypy.wordpress.com/?p=14</guid>
		<description><![CDATA[How can you log with Log4J in all your Groovy classes without importing anything and without boilerplate code to initialize the logger in every class.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=groovypy.wordpress.com&amp;blog=9670182&amp;post=14&amp;subd=groovypy&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In Java I allways used the Log4J Logger directly because I never understood the advantage of an abstract logging framework. I used to write something like this in all my classes to log in instance methods:</p>
<pre class="brush: plain;">
import org.apache.log4j.Logger;

class Foo {
  private final Logger log = Logger.getLogger(this.getClass());
}
</pre>
<p>In Java I repeated this in every and all of my classes. Now working almost only with Groovy this does not feel right anymore. It does not feel <a href="http://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY</a>. My solution is to have a static initializer block in one class to teach all my objects how to log. This, like the Java variant above, is limited to instance logging. As I avoid static methods this works for me. </p>
<pre class="brush: plain;">
import org.apache.log4j.*

static {
	def logPattern = new PatternLayout('%r %-5p [%c{1}] %m%n')
	def level = Level.TRACE
	BasicConfigurator.configure(new ConsoleAppender(logPattern))
	BasicConfigurator.configure(new FileAppender(logPattern, &quot;${applicationName}.log&quot;))
	LogManager.rootLogger.level = level

	Object.metaClass.static.getLogger = {
		-&gt; Logger.getLogger(delegate.class)
	}
	Object.metaClass.static.logTrace = { Object msg, Throwable ex = null -&gt;
		delegate.logger.trace msg, ex
	}
	Object.metaClass.static.logDebug = { Object msg, Throwable ex = null -&gt;
		delegate.logger.debug msg, ex
	}
	Object.metaClass.static.logInfo = { Object msg, Throwable ex = null -&gt;
		delegate.logger.info msg, ex
	}
	Object.metaClass.static.logWarn = { Object msg, Throwable ex = null -&gt;
		delegate.logger.warn msg, ex
	}
	Object.metaClass.static.logError = { Object msg, Throwable ex = null -&gt;
		delegate.logger.error msg, ex
	}
	Object.metaClass.static.logFatal = { Object msg, Throwable ex = null -&gt;
		delegate.logger.fatal msg, ex
	}
}
</pre>
<p>You have now added the static methods getLogger, logTrace, logDebug, logInfo, logWarn, logError and logFatal to the class Object. With this in place you can now log in any instance method without importing anything:</p>
<pre class="brush: plain;">
logTrace &quot;${applicationName} start at: ${Calendar.instance.time}&quot;
logWarn 'Too many bad fingers on keyboard'
</pre>
<p>Enjoy and if you find a way to allow logging in a static context let me know.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/groovypy.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/groovypy.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/groovypy.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/groovypy.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/groovypy.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/groovypy.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/groovypy.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/groovypy.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/groovypy.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/groovypy.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/groovypy.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/groovypy.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/groovypy.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/groovypy.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=groovypy.wordpress.com&amp;blog=9670182&amp;post=14&amp;subd=groovypy&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://groovypy.wordpress.com/2009/09/28/14/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/320c8b9237cdd3282b14150829caf4cb?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">groovypy</media:title>
		</media:content>
	</item>
		<item>
		<title>Como calcular el Codigo Verificador del RUC en Groovy o Java?</title>
		<link>http://groovypy.wordpress.com/2009/09/26/como-calcular-el-codigo-verificador-del-ruc-en-groovy-o-java/</link>
		<comments>http://groovypy.wordpress.com/2009/09/26/como-calcular-el-codigo-verificador-del-ruc-en-groovy-o-java/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 04:08:13 +0000</pubDate>
		<dc:creator>groovypy</dc:creator>
				<category><![CDATA[español]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[paraguay]]></category>

		<guid isPermaLink="false">http://groovypy.wordpress.com/?p=3</guid>
		<description><![CDATA[En la pagina del SET hay unas funciones para calcular el digito verificador del RUC (GIOM): http://www.set.gov.py/pset/hgxpp001?6,18,273,O,S,0,PAG;CONC;287;4;D;370;1;PAG;MNU;E;103;5;MNU;, Los lenguajes listados son PL/SQL, Visual Basic y C. El mundo y Paraguay hablan más lenguajes. Porque yo trabajo normalmente con Java o Groovy yo he traducido los algoritmos en los quales lenguajes. Quando estaba en el SET [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=groovypy.wordpress.com&amp;blog=9670182&amp;post=3&amp;subd=groovypy&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>En la pagina del SET hay unas funciones para calcular el digito verificador del RUC (GIOM):<br />
<a title="SET Calcular DV" href="http://www.set.gov.py/pset/hgxpp001?6,18,273,O,S,0,PAG;CONC;287;4;D;370;1;PAG;MNU;E;103;5;MNU;," target="_blank">http://www.set.gov.py/pset/hgxpp001?6,18,273,O,S,0,PAG;CONC;287;4;D;370;1;PAG;MNU;E;103;5;MNU;,</a></p>
<p>Los lenguajes listados son PL/SQL, Visual Basic y C. El mundo y Paraguay hablan más lenguajes. Porque yo trabajo normalmente con Java o Groovy yo he traducido los algoritmos en los quales lenguajes.</p>
<p>Quando estaba en el SET para pedir un RUC me fui al otro lado de la calle donde esta ubicado el departamento de la informatica del SET para ofrecer mis traduciones. Me daron un email para enviar mis datos que hice el 17 de Julio. Yo no sé porque todavia no he escuchado nada y no han publicado. Tal vez tienen algunos errores mis traducciones que todavía no he encontrado, en este caso pido amablemente sus correcciones.</p>
<p>En el caso que mis algoritmos son útil para alguien yo seria agradecido. Por favor usan el codigo libremente, pero sabiendo que viene sin ninguna garantia <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p><strong> Groovy</strong></p>
<pre class="brush: plain;">int calcDigitoVerificador(String ruc, int basemax = 11) {
	String numeroRuc = ruc.chars.collect {
			it.isDigit() ? it : (int) it
	}.join()

	int k = 2
	int total = 0
	numeroRuc.reverse().chars.each {
			k = k &amp;gt; basemax ? 2 : k
			int numero_aux = it - 48
			total += numero_aux * k++
	}

	int resto = total % 11
	resto &amp;gt; 1 ? 11 - resto : 0
}
</pre>
<p><strong>Java</strong></p>
<pre class="brush: plain;">
int Pa_Calcular_Dv_11_A(String p_numero, int p_basemax) {
	int v_total, v_resto, k, v_numero_aux, v_digit;
	String v_numero_al = &quot;&quot;;

	for (int i = 0; i &lt; p_numero.length(); i++) {
			char c = p_numero.charAt(i);
			if(Character.isDigit(c)) {
					v_numero_al += c;
			} else {
					v_numero_al += (int) c;
			}
	}

	k = 2;
	v_total = 0;

	for(int i = v_numero_al.length() - 1; i &gt;= 0; i--) {
			k = k &gt; p_basemax ? 2 : k;
			v_numero_aux = v_numero_al.charAt(i) - 48;
			v_total += v_numero_aux * k++;
	}

	v_resto = v_total % 11;
	v_digit = v_resto &gt; 1 ? 11 - v_resto : 0;

	return v_digit;
}
</pre>
<p>También yo tengo un programa para probar mis funciones con el cual yo he encontrado 5 errores en los 10 archivos publicado en la pagina &#8220;Listado de Equivalencias de RUC&#8221;. Si alguien esta interesado también yo puedo publicar mis unit tests (pruebas unitarias &#8211; gracias Luis) y un reporte de los resultados.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/groovypy.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/groovypy.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/groovypy.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/groovypy.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/groovypy.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/groovypy.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/groovypy.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/groovypy.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/groovypy.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/groovypy.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/groovypy.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/groovypy.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/groovypy.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/groovypy.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=groovypy.wordpress.com&amp;blog=9670182&amp;post=3&amp;subd=groovypy&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://groovypy.wordpress.com/2009/09/26/como-calcular-el-codigo-verificador-del-ruc-en-groovy-o-java/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/320c8b9237cdd3282b14150829caf4cb?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">groovypy</media:title>
		</media:content>
	</item>
		<item>
		<title>What is this Blog about?</title>
		<link>http://groovypy.wordpress.com/2009/09/25/what-is-this-blog-about/</link>
		<comments>http://groovypy.wordpress.com/2009/09/25/what-is-this-blog-about/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 02:19:06 +0000</pubDate>
		<dc:creator>groovypy</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://groovypy.wordpress.com/?p=35</guid>
		<description><![CDATA[I am a software developer and cultural pessimist living in Paraguay. This blog usually will usually be about things I want to remember, discuss or share while working with Groovy, Java and sometimes C++ and Smalltalk. Occasionally I also will be writing about the beautiful country I am living in or probably about a cooking [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=groovypy.wordpress.com&amp;blog=9670182&amp;post=35&amp;subd=groovypy&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am a software developer and cultural pessimist living in Paraguay. This blog usually will usually be about things I want to remember, discuss or share while working with Groovy, Java and sometimes C++ and Smalltalk. </p>
<p>Occasionally I also will be writing about the beautiful country I am living in or probably about a cooking recipe or a book I&#8217;m reeding or some general thoughts about live. I will tag my writings so it should be easy to filter out anything which is noise for the estimated reader which is hopefully you.</p>
<p>I will usually blog in English, but sometimes it could be in Spanish or in German. For the language I use categories, this is your second option to filter this blog.</p>
<p>So welcome to my blog and I hope you will find something interesting for you.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/groovypy.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/groovypy.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/groovypy.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/groovypy.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/groovypy.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/groovypy.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/groovypy.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/groovypy.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/groovypy.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/groovypy.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/groovypy.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/groovypy.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/groovypy.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/groovypy.wordpress.com/35/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=groovypy.wordpress.com&amp;blog=9670182&amp;post=35&amp;subd=groovypy&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://groovypy.wordpress.com/2009/09/25/what-is-this-blog-about/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/320c8b9237cdd3282b14150829caf4cb?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">groovypy</media:title>
		</media:content>
	</item>
	</channel>
</rss>
