<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        color:black;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New",serif;
        color:black;}
tt
        {mso-style-priority:99;
        font-family:"Courier New",serif;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;
        color:black;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.EmailStyle21
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle22
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle23
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="SV" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New",serif;color:windowtext">Hi Bogdan,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New",serif;color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New",serif;color:windowtext">Perhaps variables should be evaluated when passed as arguments to a route? Then it would be possible to replace a function call like this:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New",serif;color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New",serif;color:windowtext">xlog("L_INFO", "$rm received on $var(hostname)");<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New",serif;color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New",serif;color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New",serif;color:windowtext">with a call to a sub-route:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New",serif;color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New",serif;color:windowtext">route(LOG, "$rm received on $var(hostname)");<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New",serif;color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New",serif;color:windowtext">route[LOG] {<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New",serif;color:windowtext"> # do some common stuff here<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New",serif;color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New",serif;color:windowtext"> xlog(“L_INFO”, $param(1));<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New",serif;color:windowtext">}<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Courier New",serif;color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext">Best regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext">Jan<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="color:windowtext;mso-fareast-language:SV">From:</span></b><span lang="EN-US" style="color:windowtext;mso-fareast-language:SV"> Bogdan-Andrei Iancu [mailto:bogdan@opensips.org]
<br>
<b>Sent:</b> den 5 december 2016 09:59<br>
<b>To:</b> Jan Blom <jan.blom@peopleinteractive.se>; OpenSIPS users mailling list <users@lists.opensips.org><br>
<b>Subject:</b> Re: [OpenSIPS-Users] Problem using xlog with variables<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><tt><span style="font-size:10.0pt">Hi Jan,</span></tt><span style="font-size:10.0pt;font-family:"Courier New",serif"><br>
<br>
<tt>Of course you can, but you need to evaluate the variables before passing it to the route (as param)</tt><br>
<br>
<tt>$var(msg) = rm + "received on " + $var(hostname);</tt><br>
<tt>route(logger, $var(msg));</tt><br>
<br>
<tt>Regards,</tt></span><br>
<span style="font-size:10.0pt;font-family:"Courier New",serif"><br>
<br>
</span><span style="font-size:12.0pt;mso-fareast-language:SV"><o:p></o:p></span></p>
<pre>Bogdan-Andrei Iancu<o:p></o:p></pre>
<pre>OpenSIPS Founder and Developer<o:p></o:p></pre>
<pre><a href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a><o:p></o:p></pre>
<div>
<p class="MsoNormal">On 04.12.2016 21:29, Jan Blom wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext">Hi Bogdan,</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext">Thank you for the clarification. I was suspecting that.
</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext">That means I cannot simply drop-in replace calls to xlog with calls to a route and passing the log message as an argument.</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext">What do you think about adding a core function eval() that evaluates a string (possibly recursively)?</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext">Best regards,</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext">Jan</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext"> </span><o:p></o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="color:windowtext;mso-fareast-language:SV">From:</span></b><span lang="EN-US" style="color:windowtext;mso-fareast-language:SV"> Bogdan-Andrei Iancu [<a href="mailto:bogdan@opensips.org">mailto:bogdan@opensips.org</a>]
<br>
<b>Sent:</b> den 2 december 2016 09:57<br>
<b>To:</b> OpenSIPS users mailling list <a href="mailto:users@lists.opensips.org">
<users@lists.opensips.org></a>; Jan Blom <a href="mailto:jan.blom@peopleinteractive.se">
<jan.blom@peopleinteractive.se></a><br>
<b>Subject:</b> Re: [OpenSIPS-Users] Problem using xlog with variables</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><tt><span style="font-size:10.0pt">Hi Jan,</span></tt><span style="font-size:10.0pt;font-family:"Courier New",serif"><br>
<br>
<tt>You can print via variables strings containing again references to other variables - there is only one level of variable evaluation.
</tt><br>
<br>
<tt>You should do it:</tt><br>
<tt> $var(msg) = $rm + "received on " + $var(hostname);</tt><br>
<tt> xlog("L_INFO", "$var(msg)");</tt><br>
<tt> </tt><br>
<tt>Regards,</tt><br>
<br>
<br>
</span><o:p></o:p></p>
<pre>Bogdan-Andrei Iancu<o:p></o:p></pre>
<pre>OpenSIPS Founder and Developer<o:p></o:p></pre>
<pre><a href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a><o:p></o:p></pre>
<div>
<p class="MsoNormal">On 01.12.2016 23:36, Jan Blom wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">Hello all,<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">I was going to centralized logging functions to a route block that would be called from various place in script, using $param(n) to access the log message. I got stuck on what I guess is variable evaluation. Simplified
this is the problem:</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">The normal (working) way:</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">xlog("L_INFO", "$rm received on $var(hostname)");
</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">Output: INVITE received on proxy-stage-01</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">What I was trying:</span><o:p></o:p></p>
<p class="MsoNormal">$var(msg) = "$rm received on $var(hostname)";<o:p></o:p></p>
<p class="MsoNormal">xlog("L_INFO", "$var(msg)");<o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">Output: $rm received on $var(hostname)</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">In the latter case the variables are not evaluated the way I was expecting.
</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">Is there a better way to achieve the output of the first example by using a variable containing the message to xlog?</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">I am testing this on OpenSIPS 2.1.</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">Best regards,</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">Jan Blom</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:12.0pt"><br>
<br>
<br>
<br>
</span><o:p></o:p></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>Users mailing list<o:p></o:p></pre>
<pre><a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><o:p></o:p></pre>
<pre><a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><o:p></o:p></pre>
</blockquote>
<p class="MsoNormal"><span style="font-size:12.0pt"> </span><o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-language:SV"><o:p> </o:p></span></p>
</div>
</body>
</html>