Commit a1f45ff7 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

#13652: Make SIP log level should be controlable from environment variable

parent 10319d91
......@@ -72,6 +72,7 @@
#include <arpa/inet.h>
#include <resolv.h>
#include <istream>
// #include <fstream>
#include <utility> // for std::pair
#include <map>
......@@ -83,6 +84,9 @@ bool SIPVoIPLink::destroyed_ = false;
namespace {
/** Environment variable used to set pjsip's logging level */
#define SIPLOGLEVEL "SIPLOGLEVEL"
/** A map to retreive SFLphone internal call id
* Given a SIP call ID (usefull for transaction sucha as transfer)*/
static std::map<std::string, std::string> transferCallID;
......@@ -417,8 +421,8 @@ SIPVoIPLink::SIPVoIPLink() : sipTransport(endpt_, cp_, pool_), evThread_(this)
TRY(pj_init());
TRY(pjlib_util_init());
// From 0 (min) to 6 (max)
pj_log_set_level(6);
setSipLogLevel();
TRY(pjnath_init());
pj_caching_pool_init(cp_, &pj_pool_factory_default_policy, 0);
......@@ -521,6 +525,22 @@ void SIPVoIPLink::destroy()
instance_ = 0;
}
void SIPVoIPLink::setSipLogLevel()
{
std::string loglevel = getenv(SIPLOGLEVEL);
int level = 0;
if(!loglevel.empty()) {
if ( ! (std::istringstream(loglevel) >> level) ) level = 0;
level = level > 6 ? 6 : level;
level = level < 0 ? 0 : level;
}
// From 0 (min) to 6 (max)
pj_log_set_level(level);
}
// Called from EventThread::run (not main thread)
bool SIPVoIPLink::getEvent()
{
......
......@@ -78,6 +78,13 @@ class SIPVoIPLink : public VoIPLink {
*/
static void destroy();
/**
* Set pjsip's log level based on the SIPLOGLEVEL environment variable.
* SIPLOGLEVEL = 0 minimum logging
* SIPLOGLEVEL = 6 maximum logging
*/
static void setSipLogLevel();
/**
* Event listener. Each event send by the call manager is received and handled from here
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment