<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2015-05-12 13:48 GMT+02:00 Tzafrir Cohen <span dir="ltr"><<a href="mailto:tzafrir.cohen@xorcom.com" target="_blank">tzafrir.cohen@xorcom.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On Mon, May 11, 2015 at 11:26:31PM +0200, Ludovic Gasc wrote:<br>
<br>
> The idea behind structured log is to retrieve easily a context with a log<br>
> to reduce the effort of categorization after, because you don't need to<br>
> parse and recognize patterns in log message.<br>
> Technically, instead of to have a String, you have a Dict of Strings.<br>
<br>
</span>That's nice in theory. Could you please give an example of the required<br>
output? An example of how it would help?<br></blockquote><div><br></div><div>For now, this is the situation to log for most applications:</div><div>1. In your source code, where you want to log, you aggregate data from several variables to generate a log message. Example:</div><div>    <a href="http://logger.info">logger.info</a>('This is a call from "%s" with the uniqueid "%s" and callerid "%s" to call "%s" extension in "%s" context', endpoint, uniqueid, callerid, extension, context)</div><div><br></div><div>2. This message is stored in the text format in /var/log/asterisk/debug.log</div><div><br></div><div>3. For example, to retrieve all logs about a specific extension, the sysadmin needs to use: grep -i "\"%s\" extension" /var/log/asterisk/debug.log or write regex for a log analysis tool, with a risk of false positive or miss something.</div><div><br></div><div>At the beginning, in your source code, you have structured data, you encode as string for log.</div><div>After, to get metadata in logs, you need to decode your logs with regex to retrieve structured data to query inside.</div><div><br></div><div>The final situation should be:</div><div><a href="http://logger.info">logger.info</a>('This is a call from "%(endpoint)s" with the uniqueid "%(uniqueid)s" and callerid "%(callerid)s" to call "%(extension)s" extension in "%(context)s" context', {'endpoint': endpoint, 'uniqueid': uniqueid, 'callerid': callerid, 'extension': extension, 'context': context})</div><div><br></div><div>And after, depends on the handler:</div><div>    a. For syslog, you use the dict only to replace values in string</div><div>    b. For journald, you push also the dict with the log message. With that, you don't need to encode/decode, you retrieve directly structured data included in message log.</div><div><br></div><div>And yes, ideally, it should be useful if we can generate log messages with the structured data directly in the dialplan.</div><div>BTW, you just give me an interesting idea to have this feature easily: I can make a FastAGI daemon that generate my journald message, based on data pushed as parameter with a JSON dict structure.</div><div>Not really funny to write the dialplan source code, however, it will work.</div><div><br></div><div>If it isn't enough concrete for you, I can give you a concrete example with a click2call HTTP endpoint, where the order starts from WebBrowser, to finish in asterisk.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span class=""><font color="#888888"><br>
--<br>
               Tzafrir Cohen<br>
icq#16849755              <a href="mailto:jabber%3Atzafrir.cohen@xorcom.com">jabber:tzafrir.cohen@xorcom.com</a><br>
<a href="tel:%2B972-50-7952406" value="+972507952406">+972-50-7952406</a>           mailto:<a href="mailto:tzafrir.cohen@xorcom.com">tzafrir.cohen@xorcom.com</a><br>
<a href="http://www.xorcom.com" target="_blank">http://www.xorcom.com</a><br>
</font></span><div class=""><div class="h5"><br>
--<br>
_____________________________________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank">http://www.api-digital.com</a> --<br>
<br>
asterisk-dev mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
   <a href="http://lists.digium.com/mailman/listinfo/asterisk-dev" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-dev</a><br>
</div></div></blockquote></div><br></div></div>