Enable Logging Emails "Ad-Hoc" in Ruby Dial Plan
Enable Logging Emails "Ad-Hoc" in Ruby Dial Plan
How do you enable Logging (i.e. email notifications) within the Dial Plan?
e.g. Dial Plan starts with error_logging = disabled.
When xxxx then error_logging = enabled and continue.
etc.
Just so you can either enter a line of code in an IF, CASE, module, etc. to eliminate unneccssary email alerts.
That is the whole point of error notifications, being able to tell Ruby to send them when a trigger is switched on.
Or maybe it is ON from start and then turned OFF once it finds a rule.
Could someone please provide 1-2 examples on how this can be used effectively, or if there is more than one way to enable/disable logging in Ryby.
THANK YOU!
e.g. Dial Plan starts with error_logging = disabled.
When xxxx then error_logging = enabled and continue.
etc.
Just so you can either enter a line of code in an IF, CASE, module, etc. to eliminate unneccssary email alerts.
That is the whole point of error notifications, being able to tell Ruby to send them when a trigger is switched on.
Or maybe it is ON from start and then turned OFF once it finds a rule.
Could someone please provide 1-2 examples on how this can be used effectively, or if there is more than one way to enable/disable logging in Ryby.
THANK YOU!
ISP: Southern Phone ADSL2+ $55 Bundle. 22.4/1.2Mbps, ∞GB Bundle [Telstra].
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
Re: Enable Logging Emails "Ad-Hoc" in Ruby Dial Plan
There is no way to turn off the automatic log messages in a sipsorcery dialplan. You can use your own logic to decide whether to make additional sys.Log calls but as far as the inbuilt ones go they will always show up in your Console traces.
If you want to generate your own diagnostic output and email it somewhere you could store your own log output in a variable and then use the sys.Email function to send it. The difficulty with this approach is that when a forwarded call is answered the dialplan immediately terminates. If you only want to send an email when all call forwards fail then you can place the sys.Email call at the end of your dialplan.
If you can provide a little bit more information about your intentions I should be able to give you a Ruby sample.
If you want to generate your own diagnostic output and email it somewhere you could store your own log output in a variable and then use the sys.Email function to send it. The difficulty with this approach is that when a forwarded call is answered the dialplan immediately terminates. If you only want to send an email when all call forwards fail then you can place the sys.Email call at the end of your dialplan.
If you can provide a little bit more information about your intentions I should be able to give you a Ruby sample.
Re: Enable Logging Emails "Ad-Hoc" in Ruby Dial Plan
Cheers Aaron.
Well as you said, rather than just return a 404 error at the end (which does very little during testing, implementation and debugging), the idea was to include the same debug info I have at the top of my dial plan (unless there is another way to dump the relevant info in one command).
e.g.
or something like this (pseudo code):
Does that make sense? So basically catching more details of the error, failure, warning, etc. Rather than it being lost in the Silverlight Console which only seems to keep track of 300 lines (IF ... IF enabled!!!).
I think delving into database queries et al, is stepping it up another level for me.
Would be fantastic if there was something available for all SS members so they can perform some diagnostic debugging and troubleshooting.
Cheers!
Well as you said, rather than just return a 404 error at the end (which does very little during testing, implementation and debugging), the idea was to include the same debug info I have at the top of my dial plan (unless there is another way to dump the relevant info in one command).
e.g.
Code: Select all
sys.trace = false
case ....
when ...
when ...
when ..., ..., ... then sys.trace=true, sys.log ...., sys.dial....
else
sys.trace = true
sys.log ...
sys.respond ...
end.
Code: Select all
if sys.error-code >= 200 then catcherror and sys.trace(email=true)
else if sys.error-code < 200 then continue
or sys.trace(_error code_, default message or current call details and stats.)
or sys.email(email, .......\n
new line of text in email...\n
Error Log: include_error)
I think delving into database queries et al, is stepping it up another level for me.
Would be fantastic if there was something available for all SS members so they can perform some diagnostic debugging and troubleshooting.
Cheers!
ISP: Southern Phone ADSL2+ $55 Bundle. 22.4/1.2Mbps, ∞GB Bundle [Telstra].
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
Re: Enable Logging Emails "Ad-Hoc" in Ruby Dial Plan
So could you record all your log messages in a list and then at the very end of your dialplan call the sys.Email function? If the call is successfully answered the sys.Email call will never be reached. If the call fails you'll get an email with your log messages. Unfortunately that won't get you any of the internal log messages from the "sys" functions.Flip wrote:Well as you said, rather than just return a 404 error at the end (which does very little during testing, implementation and debugging), the idea was to include the same debug info I have at the top of my dial plan (unless there is another way to dump the relevant info in one command).
Code: Select all
# Create an empty Ruby array
@log = []
# Do your stuff and add log messages to the array as you go.
@log << "Hello World"
@log << "Nice Day"
@log << "Hohum"
@log << "Bye"
#At the very end of your dialplan send the email.
sys.Email(someone@somewhere.com", "Test Log Email", @log.join("\n"))
If you can find a public SIP service with anything close to the diagnostic facilities available with sipsorcery I'd be amazed. As mentioned previously I've used over 50 providers and I can only think of one, tropo.com, that had any sort of diagnostics at all and in that case it was a web based live trace the same as the sipsorcery console. WIth sipsorcery you've got the Console + the automatic email traces + the SSH console + the ability to capture full raw SIP exchanges!Flip wrote:I think delving into database queries et al, is stepping it up another level for me.
Would be fantastic if there was something available for all SS members so they can perform some diagnostic debugging and troubleshooting.
Re: Enable Logging Emails "Ad-Hoc" in Ruby Dial Plan
*Bowing Down*
Aaron you are a legend.
Thank you for that. Really appreciated.
Can you get that email to be multi-lined?
sys.email(email, .......some variables...\n\r
new line of text in body...\n\r
Error Log: @include_error_array)
While capturing the array contents, do you have to add a new line or is it done automatically?
@log << "Hello World\n\r"
Will test this evening.
Ciao
Aaron you are a legend.
Thank you for that. Really appreciated.
Can you get that email to be multi-lined?
sys.email(email, .......some variables...\n\r
new line of text in body...\n\r
Error Log: @include_error_array)
While capturing the array contents, do you have to add a new line or is it done automatically?
@log << "Hello World\n\r"
Will test this evening.
Ciao
ISP: Southern Phone ADSL2+ $55 Bundle. 22.4/1.2Mbps, ∞GB Bundle [Telstra].
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
Re: Enable Logging Emails "Ad-Hoc" in Ruby Dial Plan
The bit below should make the email multi-lined:
@log.join("\n")
It does for me with Gmail.
If that doesn't work you can try replacing the "\n" with "\r\n" or "<\br>" to see what works in your email client.
@log.join("\n")
It does for me with Gmail.
If that doesn't work you can try replacing the "\n" with "\r\n" or "<\br>" to see what works in your email client.
Re: Enable Logging Emails "Ad-Hoc" in Ruby Dial Plan
Brilliant mate!
I will let you know.
I will let you know.
ISP: Southern Phone ADSL2+ $55 Bundle. 22.4/1.2Mbps, ∞GB Bundle [Telstra].
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
Re: Enable Logging Emails "Ad-Hoc" in Ruby Dial Plan
It's been so long I've completely forgotten what I was doing... or trying to achieve... Will have to try again this week...
Thanks for your response Aaron.
Cheers,
All I could find...
Thanks for your response Aaron.
Cheers,
All I could find...
The log message priorities, in order from least to most important, are as follows: debug, info, warn, error and fatal. To set the level of messages the logger should ignore, use the level attribute.
To enable log rotation, pass 'monthly', 'weekly', or 'daily' to the Logger constructor. Optionally, you can pass a maximum file size and number of files to to keep in rotation to the constructor.Code: Select all
#!/usr/bin/env ruby require 'logger' log = Logger.new('log.txt') log.level = Logger::WARN log.debug "This will be ignored" log.error "This will not be ignored"
Code: Select all
#!/usr/bin/env ruby require 'logger' log = Logger.new( 'log.txt', 'daily' ) log.debug "Once the log becomes at least one" log.debug "day old, it will be renamed and a" log.debug "new log.txt file will be created."
ISP: Southern Phone ADSL2+ $55 Bundle. 22.4/1.2Mbps, ∞GB Bundle [Telstra].
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
Re: Enable Logging Emails "Ad-Hoc" in Ruby Dial Plan
You can't save any kind of log file from your sipsorcery dailplan. You have the email facility and the Console for diagnostics.
Re: Enable Logging Emails "Ad-Hoc" in Ruby Dial Plan
Thanks.
Back on track.
Cheers Aaron.
Back on track.
Cheers Aaron.
@log = []
@log << "Hello World"
@log << "Nice Day"
@log << "Hohum"
@log << "Bye"
sys.Email(someone@somewhere.com", "Test Log Email", @log.join("\n"))
ISP: Southern Phone ADSL2+ $55 Bundle. 22.4/1.2Mbps, ∞GB Bundle [Telstra].
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.
VSP: SIPTalk¹, Symbio² & MyNetFone³ via SIPSorcery Cloud PBX. [Warning! Avoid DIDLogic!!! Beware!!]
H/W: Asus RT-AC86U; Cisco SPA232D, 2 x SPA901's, SPA3102; Yealink SIP-T46G.