<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <tt>Hi Jan,<br>
      <br>
      Of course you can, but you need to evaluate the variables before
      passing it to the route (as param)<br>
      <br>
      <span style="font-size: 10pt;"><tt><tt>$<tt>var(msg<tt>) = </tt></tt></tt></tt>rm
        + "received on " + $var(hostname);</span><br>
      <span style="font-size: 10pt;">route(logger, $var(msg));</span><span
        style="font-size: 10pt;"></span><br>
      <span style="font-size: 10pt;"></span><br>
      <span style="font-size: 10pt;">Regards,</span></tt><br>
    <tt><tt><tt><tt><tt><tt><tt><tt><tt><tt><span
                          style="font-size:10.0pt;font-family:&quot;Courier
                          New&quot;"></span></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt><tt><tt><tt><tt><tt><tt><tt><tt><br>
                  </tt></tt></tt></tt></tt></tt></tt></tt>
    <pre class="moz-signature" cols="72">Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a class="moz-txt-link-freetext" href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a></pre>
    <div class="moz-cite-prefix">On 04.12.2016 21:29, Jan Blom wrote:<br>
    </div>
    <blockquote
cite="mid:HE1PR0502MB3097E2E65F7793ECC1F62D20EE800@HE1PR0502MB3097.eurprd05.prod.outlook.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <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";
        color:black;}
tt
        {mso-style-priority:99;
        font-family:"Courier New";}
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-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]-->
      <div class="WordSection1">
        <p class="MsoNormal"><span style="color:windowtext" lang="EN-US">Hi
            Bogdan,<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:windowtext" lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:windowtext" lang="EN-US">Thank
            you for the clarification. I was suspecting that.
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:windowtext" lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:windowtext" lang="EN-US">That
            means I cannot simply drop-in replace calls to xlog with
            calls to a route and passing the log message as an argument.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:windowtext" lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:windowtext" lang="EN-US">What
            do you think about adding a core function eval() that
            evaluates a string (possibly recursively)?<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:windowtext" lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:windowtext" lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:windowtext" lang="EN-US">Best
            regards,<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:windowtext" lang="EN-US">Jan<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:windowtext" lang="EN-US"><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
                  style="color:windowtext;mso-fareast-language:SV"
                  lang="EN-US">From:</span></b><span
                style="color:windowtext;mso-fareast-language:SV"
                lang="EN-US"> Bogdan-Andrei Iancu
                [<a class="moz-txt-link-freetext" 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 class="moz-txt-link-rfc2396E" href="mailto:users@lists.opensips.org">&lt;users@lists.opensips.org&gt;</a>; Jan Blom
                <a class="moz-txt-link-rfc2396E" href="mailto:jan.blom@peopleinteractive.se">&lt;jan.blom@peopleinteractive.se&gt;</a><br>
                <b>Subject:</b> Re: [OpenSIPS-Users] Problem using xlog
                with variables<o:p></o:p></span></p>
          </div>
        </div>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><tt><span style="font-size:10.0pt">Hi Jan,</span></tt><span
            style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><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>
          </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 moz-do-not-send="true" 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;font-family:&quot;Times New
              Roman&quot;,serif;mso-fareast-language:SV"><br>
              <br>
              <br>
              <o:p></o:p></span></p>
          <pre>_______________________________________________<o:p></o:p></pre>
          <pre>Users mailing list<o:p></o:p></pre>
          <pre><a moz-do-not-send="true" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><o:p></o:p></pre>
          <pre><a moz-do-not-send="true" 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;font-family:&quot;Times New
            Roman&quot;,serif;mso-fareast-language:SV"><o:p> </o:p></span></p>
      </div>
    </blockquote>
    <br>
  </body>
</html>