[asterisk-users] (no subject)
Steve Edwards
asterisk.org at sedwards.com
Tue Oct 20 14:36:55 CDT 2009
On Tue, 20 Oct 2009, mickael ropars wrote:
> I want to know if it's possible to create a log file per context? and
> each time a context is restarted a ne x log file is created.
This is not clear to me. Contexts are not "restarted." What are you trying
to log?
Asterisk has the system() application which will execute any arbitrary
Linux command line so you can do pretty much anything.
Asterisk doesn't have the "native" ability to create log files as I think
you described. How would you handle 2 calls entering the same context at
effectively the same time? There are "race" conditions to consider both
for file creation and writing.
Maybe this will give you some ideas:
[wildcard-test]
exten = _!,1, verbose(1,[${CONTEXT}:${EXTEN}])
exten = _!,n, system(logger -i -p local0.info -t ${CONTEXT} ${CALLERID(num)} entered context)
exten = _!,n, answer()
exten = _!,n, hangup()
exten = _x,4, playback(demo-congrats)
exten = _x,n, system(logger -i -p local0.info -t ${CONTEXT} ${CALLERID(num)} finished)
exten = _x,n, hangup()
exten = h,2, system(logger -i -p local0.info -t ${CONTEXT} ${CALLERID(num)} hung up)
exten = h,n, hangup()
This will log every entry to the context to syslogd. You can configure
syslogd (/etc/syslog.conf) to separate the log entries as desired.
This is pretty inefficient -- it creates at least 4 processes (2 on entry,
2 on hangup) for every call.
I had an application several years ago that required logging how long each
caller was in each context. I used resetcdr(w) and "enhanced"
cdr_addon_mysql.c. When the call finished, I executed an AGI that added up
the "cdrs" and rated the call.
If you post questions with meaningful subject lines, you may attract the
interest of someone who has solved your exact problem and you make it
easier for the next guy to research.
--
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST
Newline Fax: +1-760-731-3000
More information about the asterisk-users
mailing list