<div dir="ltr"><div><div><div><div>Manoel,<br><br></div>Eu utilizo o Log4Perl e gosto dele por ser independente e permitir expandir a saida para quase tudo que existe hj, e se não existir é só fazer um plugin.<br><br></div>

Não recomendo fazer um sistema de log proprietário .<br><br></div>Se eu não estiver enganado, o Log::Any é uma interface/bind para vários tipos de Log.<br><br></div>Solli Honorio<br><div><br></div></div><div class="gmail_extra">

<br><br><div class="gmail_quote">Em 5 de março de 2014 13:05, Manoel Domingues Junior <span dir="ltr"><<a href="mailto:manoel.domingues.junior@gmail.com" target="_blank">manoel.domingues.junior@gmail.com</a>></span> escreveu:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Olá pessoal,<div><br></div><div>Estou fazendo uns scripts(na verdade é uma API com Mojolicious::Lite) aqui e implementei uma função de log usando um conjunto de Net::Syslog com Sys::Syslog para fazer o log do script.</div>



<div><br></div><div><a href="https://gist.github.com/mdjunior/9369937" target="_blank">https://gist.github.com/mdjunior/9369937</a></div><div><br></div><div><pre style="line-height:16.799999237060547px;width:744px;font-size:12px;margin-bottom:0px;font-family:Consolas,'Liberation Mono',Courier,monospace;margin-top:0px;padding:0px">


<div><span style="font-weight:bold">sub </span><span style="color:rgb(153,0,0);font-weight:bold">log_wrapper</span> <span>{</span></div><div>

    <span style="font-weight:bold">my</span> <span style="color:teal">$log</span> <span style="font-weight:bold">=</span> <span style="color:rgb(0,134,179)">shift</span><span>;</span></div>

<div>    <span style="font-weight:bold">my</span> <span style="color:teal">$priority</span> <span style="font-weight:bold">=</span> <span style="color:rgb(0,134,179)">shift</span><span>;</span></div>

<div> </div><div><span style="font-weight:bold"><span style="font-weight:normal">    </span>if</span> <span>(</span> <span style="font-weight:bold">!</span> <span style="color:rgb(0,134,179)">defined</span> <span style="color:teal">$priority</span> <span>)</span> <span>{</span></div>



<div>     <span style="color:teal">$priority</span> <span style="font-weight:bold">=</span> <span style="color:rgb(221,17,68)">'debug'</span><span>;</span></div>

<div><span>    }</span></div><div> </div><div>    <span style="font-weight:bold">if</span> <span>(</span> <span style="color:teal">$ENV</span><span>{</span><span style="color:rgb(51,51,51)">APP_LOG</span><span>}</span> <span style="font-weight:bold">eq</span> <span style="color:rgb(221,17,68)">'LOCAL'</span> <span>)</span> <span>{</span></div>



<div>        <span style="color:rgb(51,51,51)">openlog</span><span>(</span> <span style="color:teal">$ENV</span><span>{</span><span style="color:rgb(51,51,51)">APP_NAME</span><span>}</span><span>,</span> <span style="color:rgb(221,17,68)">'ndelay,pid'</span><span>,</span> <span style="color:rgb(221,17,68)">'LOG_DAEMON'</span> <span>);</span></div>



<div>        <span style="color:rgb(51,51,51)">syslog</span><span>(</span> <span style="color:teal">$priority</span><span>,</span> <span style="color:teal">$log</span> <span>);</span></div>

<div>        <span style="color:rgb(51,51,51)">closelog</span><span>();</span></div><div>    <span>}</span> <span style="font-weight:bold">elsif</span> <span>(</span><span style="color:teal">$ENV</span><span>{</span><span style="color:rgb(51,51,51)">APP_LOG</span><span>}</span> <span style="font-weight:bold">eq</span> <span style="color:rgb(221,17,68)">'NET'</span><span>)</span> <span>{</span></div>



<div>        <span style="font-weight:bold">my</span> <span style="color:teal">$log_net</span> <span style="font-weight:bold">=</span> <span style="color:rgb(85,85,85)">Net::</span><span style="color:rgb(51,51,51)">Syslog</span><span style="font-weight:bold">-></span><span style="font-weight:bold">new</span><span>(</span></div>



<div>                                <span style="color:rgb(51,51,51)">Name</span> <span style="font-weight:bold">=></span> <span style="color:teal">$ENV</span><span>{</span><span style="color:rgb(51,51,51)">APP_NAME</span><span>},</span></div>



<div>                                <span style="color:rgb(51,51,51)">Facility</span> <span style="font-weight:bold">=></span> <span style="color:rgb(221,17,68)">'local7'</span><span>,</span></div>

<div>                                <span style="color:rgb(51,51,51)">Priority</span> <span style="font-weight:bold">=></span> <span style="color:teal">$priority</span><span>,</span></div>

<div>                                <span style="color:rgb(51,51,51)">SyslogPort</span> <span style="font-weight:bold">=></span> <span style="color:teal">$ENV</span><span>{</span><span style="color:rgb(51,51,51)">APP_SYSLOG_PORT</span><span>},</span></div>



<div>                                <span style="color:rgb(51,51,51)">SyslogHost</span> <span style="font-weight:bold">=></span> <span style="color:teal">$ENV</span><span>{</span><span style="color:rgb(51,51,51)">APP_SYSLOG_HOST</span><span>},</span></div>



<div>                                <span>);</span></div><div>        <span style="color:teal">$log_net</span><span style="font-weight:bold">-></span><span style="color:rgb(0,134,179)">send</span><span>(</span><span style="color:teal">$log</span><span>);</span></div>



<div>    <span>}</span></div><div>    <span style="font-weight:bold">return</span><span>;</span></div><div>

<span>}</span></div><div><span><br></span></div></pre></div><div>Pesquisando na internet vi que muita gente comenta sobre o Log::Log4perl e o Log::Any mas não sei bem qual desses (ou outros) é o ideal ou o padrão de uso.</div>



<div><br></div><div>No caso, toda a configuração do meu script fica em variáveis de ambiente. O script possui uma trilha de auditoria que é feita usando os logs, logo ele gera eventos em grande quantidade em diferentes níveis (debug, info e error).</div>



<div><br></div><div>Alguma recomendação?</div><div><br clear="all"><div>Abraços,</div><span class="HOEnZb"><font color="#888888">-- <br>--<br>Manoel Domingues Junior<br>"Coletar dados é o primeiro passo para a sabedoria, mas compartilhar dados é o primeiro passo para a comunidade."<br>



IBM - Prodigy Linux<br>
</font></span></div></div>
<br>_______________________________________________<br>
Rio-pm mailing list<br>
<a href="mailto:Rio-pm@pm.org">Rio-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/rio-pm" target="_blank">http://mail.pm.org/mailman/listinfo/rio-pm</a><br></blockquote></div><br><br clear="all"><br>-- <br>"o animal satisfeito dorme". - Guimarães Rosa
</div>