marcelog/PAGI — pull request #10 by jacobkiers (2012-10-26 18:35:04+00:00)
Title: Add channel to logging.

Hi Marcelo,

In the process of creating a replacement voice stack based on Asterisk,
we found that we needed to add some functionality to PAGI. This is the
first of a series of PRs aimed at mainlining these changes.

This PR prefixes the Channel name to the logs. By explicitly logging
the channel, it becomes much easier to track a single call. This is
especially relevant with a lot of simultaneous calls, which we deal
with.

In the current implementation, as long as the channel name is not known,
it defaults to 'uninitialized'. This should only happen in the ::read()
method, for the first couple of AGI variables. That is somewhat annoying,
annoying but the payoff to have all the 'real' agi commands prefixed by
the channnel name is worth it.

In ClientImpl::read() we use ::_variables['channel'] instead of the
Channel Variables Facade. This is necessary, because if we use that
facade in the read() method, the facade is created before the channel
variables are received. When that happens, no channel variables will be
available.