Hi Bogdan,
Perhaps variables should be evaluated when passed as arguments to a route? Then
it would be possible to replace a function call like this:
xlog("L_INFO", "$rm received on $var(hostname)");
with a call to a sub-route:
route(LOG, "$rm received on $var(hostname)");
route[LOG] {
# do some common stuff here
xlog("L_INFO", $param(1));
}
Best regards,
Jan
From: Bogdan-Andrei Iancu [mailto:[email protected]]
Sent: den 5 december 2016 09:59
To: Jan Blom <[email protected]>; OpenSIPS users mailling list
<[email protected]>
Subject: Re: [OpenSIPS-Users] Problem using xlog with variables
Hi Jan,
Of course you can, but you need to evaluate the variables before passing it to
the route (as param)
$var(msg) = rm + "received on " + $var(hostname);
route(logger, $var(msg));
Regards,
Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com
On 04.12.2016 21:29, Jan Blom wrote:
Hi Bogdan,
Thank you for the clarification. I was suspecting that.
That means I cannot simply drop-in replace calls to xlog with calls to a route
and passing the log message as an argument.
What do you think about adding a core function eval() that evaluates a string
(possibly recursively)?
Best regards,
Jan
From: Bogdan-Andrei Iancu [mailto:[email protected]]
Sent: den 2 december 2016 09:57
To: OpenSIPS users mailling list
<[email protected]><mailto:[email protected]>; Jan Blom
<[email protected]><mailto:[email protected]>
Subject: Re: [OpenSIPS-Users] Problem using xlog with variables
Hi Jan,
You can print via variables strings containing again references to other
variables - there is only one level of variable evaluation.
You should do it:
$var(msg) = $rm + "received on " + $var(hostname);
xlog("L_INFO", "$var(msg)");
Regards,
Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com
On 01.12.2016 23:36, Jan Blom wrote:
Hello all,
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:
The normal (working) way:
xlog("L_INFO", "$rm received on $var(hostname)");
Output: INVITE received on proxy-stage-01
What I was trying:
$var(msg) = "$rm received on $var(hostname)";
xlog("L_INFO", "$var(msg)");
Output: $rm received on $var(hostname)
In the latter case the variables are not evaluated the way I was expecting.
Is there a better way to achieve the output of the first example by using a
variable containing the message to xlog?
I am testing this on OpenSIPS 2.1.
Best regards,
Jan Blom
_______________________________________________
Users mailing list
[email protected]<mailto:[email protected]>
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users