mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
support changing log level runtime (#926)
* support changing log level runtime * support changing log level runtime * support changing log level runtime
This commit is contained in:
7
app.js
7
app.js
@@ -100,8 +100,13 @@ createHttpListener(logger, srf)
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(async() => {
|
||||||
srf.locals.stats.gauge('fs.sip.calls.count', sessionTracker.count);
|
srf.locals.stats.gauge('fs.sip.calls.count', sessionTracker.count);
|
||||||
|
// Checking system log level
|
||||||
|
const systemInformation = await srf.locals.dbHelpers.lookupSystemInformation();
|
||||||
|
if (systemInformation && systemInformation.log_level) {
|
||||||
|
logger.level = systemInformation.log_level;
|
||||||
|
}
|
||||||
}, 20000);
|
}, 20000);
|
||||||
|
|
||||||
const disconnect = () => {
|
const disconnect = () => {
|
||||||
|
|||||||
@@ -258,6 +258,8 @@ router.post('/',
|
|||||||
callId: inviteReq.get('Call-ID'),
|
callId: inviteReq.get('Call-ID'),
|
||||||
accountSid,
|
accountSid,
|
||||||
traceId: rootSpan.traceId
|
traceId: rootSpan.traceId
|
||||||
|
}, {
|
||||||
|
...(account.enable_debug_log && {level: 'debug'})
|
||||||
});
|
});
|
||||||
app.requestor.logger = app.notifier.logger = sipLogger;
|
app.requestor.logger = app.notifier.logger = sipLogger;
|
||||||
const callInfo = new CallInfo({
|
const callInfo = new CallInfo({
|
||||||
|
|||||||
@@ -187,14 +187,20 @@ module.exports = function(srf, logger) {
|
|||||||
|
|
||||||
const {span} = rootSpan.startChildSpan('lookupAccountDetails');
|
const {span} = rootSpan.startChildSpan('lookupAccountDetails');
|
||||||
try {
|
try {
|
||||||
req.locals.accountInfo = await lookupAccountDetails(account_sid);
|
const accountDetail = await lookupAccountDetails(account_sid);
|
||||||
req.locals.service_provider_sid = req.locals.accountInfo?.account?.service_provider_sid;
|
const account = accountDetail?.account;
|
||||||
|
req.locals.accountInfo = accountDetail;
|
||||||
|
req.locals.service_provider_sid = account?.service_provider_sid;
|
||||||
span.end();
|
span.end();
|
||||||
if (!req.locals.accountInfo.account.is_active) {
|
if (!account?.is_active) {
|
||||||
logger.info(`Account is inactive or suspended ${account_sid}`);
|
logger.info(`Account is inactive or suspended ${account_sid}`);
|
||||||
// TODO: alert
|
// TODO: alert
|
||||||
return res.send(503, {headers: {'X-Reason': 'Account exists but is inactive'}});
|
return res.send(503, {headers: {'X-Reason': 'Account exists but is inactive'}});
|
||||||
}
|
}
|
||||||
|
// Change the default log level to debug
|
||||||
|
if (account?.enable_debug_log) {
|
||||||
|
req.locals.logger.level = 'debug';
|
||||||
|
}
|
||||||
logger.debug({accountInfo: req.locals?.accountInfo?.account}, `retrieved account info for ${account_sid}`);
|
logger.debug({accountInfo: req.locals?.accountInfo?.account}, `retrieved account info for ${account_sid}`);
|
||||||
next();
|
next();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -139,7 +139,8 @@ function installSrfLocals(srf, logger) {
|
|||||||
lookupAccountBySid,
|
lookupAccountBySid,
|
||||||
lookupAccountCapacitiesBySid,
|
lookupAccountCapacitiesBySid,
|
||||||
lookupSmppGateways,
|
lookupSmppGateways,
|
||||||
lookupClientByAccountAndUsername
|
lookupClientByAccountAndUsername,
|
||||||
|
lookupSystemInformation
|
||||||
} = require('@jambonz/db-helpers')({
|
} = require('@jambonz/db-helpers')({
|
||||||
host: JAMBONES_MYSQL_HOST,
|
host: JAMBONES_MYSQL_HOST,
|
||||||
user: JAMBONES_MYSQL_USER,
|
user: JAMBONES_MYSQL_USER,
|
||||||
@@ -215,6 +216,7 @@ function installSrfLocals(srf, logger) {
|
|||||||
lookupAccountCapacitiesBySid,
|
lookupAccountCapacitiesBySid,
|
||||||
lookupSmppGateways,
|
lookupSmppGateways,
|
||||||
lookupClientByAccountAndUsername,
|
lookupClientByAccountAndUsername,
|
||||||
|
lookupSystemInformation,
|
||||||
updateCallStatus,
|
updateCallStatus,
|
||||||
retrieveCall,
|
retrieveCall,
|
||||||
listCalls,
|
listCalls,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/* SQLEditor (MySQL (2))*/
|
/* SQLEditor (MySQL (2))*/
|
||||||
|
|
||||||
SET FOREIGN_KEY_CHECKS=0;
|
SET FOREIGN_KEY_CHECKS=0;
|
||||||
|
|
||||||
DROP TABLE IF EXISTS account_static_ips;
|
DROP TABLE IF EXISTS account_static_ips;
|
||||||
@@ -53,6 +54,8 @@ DROP TABLE IF EXISTS signup_history;
|
|||||||
|
|
||||||
DROP TABLE IF EXISTS smpp_addresses;
|
DROP TABLE IF EXISTS smpp_addresses;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS google_custom_voices;
|
||||||
|
|
||||||
DROP TABLE IF EXISTS speech_credentials;
|
DROP TABLE IF EXISTS speech_credentials;
|
||||||
|
|
||||||
DROP TABLE IF EXISTS system_information;
|
DROP TABLE IF EXISTS system_information;
|
||||||
@@ -136,6 +139,9 @@ account_sid CHAR(36) NOT NULL,
|
|||||||
is_active BOOLEAN NOT NULL DEFAULT 1,
|
is_active BOOLEAN NOT NULL DEFAULT 1,
|
||||||
username VARCHAR(64),
|
username VARCHAR(64),
|
||||||
password VARCHAR(1024),
|
password VARCHAR(1024),
|
||||||
|
allow_direct_app_calling BOOLEAN NOT NULL DEFAULT 1,
|
||||||
|
allow_direct_queue_calling BOOLEAN NOT NULL DEFAULT 1,
|
||||||
|
allow_direct_user_calling BOOLEAN NOT NULL DEFAULT 1,
|
||||||
PRIMARY KEY (client_sid)
|
PRIMARY KEY (client_sid)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -338,11 +344,23 @@ label VARCHAR(64),
|
|||||||
PRIMARY KEY (speech_credential_sid)
|
PRIMARY KEY (speech_credential_sid)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE TABLE google_custom_voices
|
||||||
|
(
|
||||||
|
google_custom_voice_sid CHAR(36) NOT NULL UNIQUE ,
|
||||||
|
speech_credential_sid CHAR(36) NOT NULL,
|
||||||
|
model VARCHAR(512) NOT NULL,
|
||||||
|
reported_usage ENUM('REPORTED_USAGE_UNSPECIFIED','REALTIME','OFFLINE') DEFAULT 'REALTIME',
|
||||||
|
name VARCHAR(64) NOT NULL,
|
||||||
|
PRIMARY KEY (google_custom_voice_sid)
|
||||||
|
);
|
||||||
|
|
||||||
CREATE TABLE system_information
|
CREATE TABLE system_information
|
||||||
(
|
(
|
||||||
domain_name VARCHAR(255),
|
domain_name VARCHAR(255),
|
||||||
sip_domain_name VARCHAR(255),
|
sip_domain_name VARCHAR(255),
|
||||||
monitoring_domain_name VARCHAR(255)
|
monitoring_domain_name VARCHAR(255),
|
||||||
|
private_network_cidr VARCHAR(8192),
|
||||||
|
log_level ENUM('info', 'debug') NOT NULL DEFAULT 'info'
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE users
|
CREATE TABLE users
|
||||||
@@ -437,11 +455,14 @@ CREATE TABLE sip_gateways
|
|||||||
sip_gateway_sid CHAR(36),
|
sip_gateway_sid CHAR(36),
|
||||||
ipv4 VARCHAR(128) NOT NULL COMMENT 'ip address or DNS name of the gateway. For gateways providing inbound calling service, ip address is required.',
|
ipv4 VARCHAR(128) NOT NULL COMMENT 'ip address or DNS name of the gateway. For gateways providing inbound calling service, ip address is required.',
|
||||||
netmask INTEGER NOT NULL DEFAULT 32,
|
netmask INTEGER NOT NULL DEFAULT 32,
|
||||||
port INTEGER NOT NULL DEFAULT 5060 COMMENT 'sip signaling port',
|
port INTEGER COMMENT 'sip signaling port',
|
||||||
inbound BOOLEAN NOT NULL COMMENT 'if true, whitelist this IP to allow inbound calls from the gateway',
|
inbound BOOLEAN NOT NULL COMMENT 'if true, whitelist this IP to allow inbound calls from the gateway',
|
||||||
outbound BOOLEAN NOT NULL COMMENT 'if true, include in least-cost routing when placing calls to the PSTN',
|
outbound BOOLEAN NOT NULL COMMENT 'if true, include in least-cost routing when placing calls to the PSTN',
|
||||||
voip_carrier_sid CHAR(36) NOT NULL,
|
voip_carrier_sid CHAR(36) NOT NULL,
|
||||||
is_active BOOLEAN NOT NULL DEFAULT 1,
|
is_active BOOLEAN NOT NULL DEFAULT 1,
|
||||||
|
send_options_ping BOOLEAN NOT NULL DEFAULT 0,
|
||||||
|
use_sips_scheme BOOLEAN NOT NULL DEFAULT 0,
|
||||||
|
pad_crypto BOOLEAN NOT NULL DEFAULT 0,
|
||||||
protocol ENUM('udp','tcp','tls', 'tls/srtp') DEFAULT 'udp' COMMENT 'Outbound call protocol',
|
protocol ENUM('udp','tcp','tls', 'tls/srtp') DEFAULT 'udp' COMMENT 'Outbound call protocol',
|
||||||
PRIMARY KEY (sip_gateway_sid)
|
PRIMARY KEY (sip_gateway_sid)
|
||||||
) COMMENT='A whitelisted sip gateway used for origination/termination';
|
) COMMENT='A whitelisted sip gateway used for origination/termination';
|
||||||
@@ -478,11 +499,19 @@ messaging_hook_sid CHAR(36) COMMENT 'webhook to call for inbound SMS/MMS ',
|
|||||||
app_json TEXT,
|
app_json TEXT,
|
||||||
speech_synthesis_vendor VARCHAR(64) NOT NULL DEFAULT 'google',
|
speech_synthesis_vendor VARCHAR(64) NOT NULL DEFAULT 'google',
|
||||||
speech_synthesis_language VARCHAR(12) NOT NULL DEFAULT 'en-US',
|
speech_synthesis_language VARCHAR(12) NOT NULL DEFAULT 'en-US',
|
||||||
speech_synthesis_voice VARCHAR(64),
|
speech_synthesis_voice VARCHAR(256),
|
||||||
speech_synthesis_label VARCHAR(64),
|
speech_synthesis_label VARCHAR(64),
|
||||||
speech_recognizer_vendor VARCHAR(64) NOT NULL DEFAULT 'google',
|
speech_recognizer_vendor VARCHAR(64) NOT NULL DEFAULT 'google',
|
||||||
speech_recognizer_language VARCHAR(64) NOT NULL DEFAULT 'en-US',
|
speech_recognizer_language VARCHAR(64) NOT NULL DEFAULT 'en-US',
|
||||||
speech_recognizer_label VARCHAR(64),
|
speech_recognizer_label VARCHAR(64),
|
||||||
|
use_for_fallback_speech BOOLEAN DEFAULT false,
|
||||||
|
fallback_speech_synthesis_vendor VARCHAR(64),
|
||||||
|
fallback_speech_synthesis_language VARCHAR(12),
|
||||||
|
fallback_speech_synthesis_voice VARCHAR(256),
|
||||||
|
fallback_speech_synthesis_label VARCHAR(64),
|
||||||
|
fallback_speech_recognizer_vendor VARCHAR(64),
|
||||||
|
fallback_speech_recognizer_language VARCHAR(64),
|
||||||
|
fallback_speech_recognizer_label VARCHAR(64),
|
||||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
record_all_calls BOOLEAN NOT NULL DEFAULT false,
|
record_all_calls BOOLEAN NOT NULL DEFAULT false,
|
||||||
PRIMARY KEY (application_sid)
|
PRIMARY KEY (application_sid)
|
||||||
@@ -525,6 +554,7 @@ siprec_hook_sid CHAR(36),
|
|||||||
record_all_calls BOOLEAN NOT NULL DEFAULT false,
|
record_all_calls BOOLEAN NOT NULL DEFAULT false,
|
||||||
record_format VARCHAR(16) NOT NULL DEFAULT 'mp3',
|
record_format VARCHAR(16) NOT NULL DEFAULT 'mp3',
|
||||||
bucket_credential VARCHAR(8192) COMMENT 'credential used to authenticate with storage service',
|
bucket_credential VARCHAR(8192) COMMENT 'credential used to authenticate with storage service',
|
||||||
|
enable_debug_log BOOLEAN NOT NULL DEFAULT false,
|
||||||
PRIMARY KEY (account_sid)
|
PRIMARY KEY (account_sid)
|
||||||
) COMMENT='An enterprise that uses the platform for comm services';
|
) COMMENT='An enterprise that uses the platform for comm services';
|
||||||
|
|
||||||
@@ -619,6 +649,10 @@ ALTER TABLE speech_credentials ADD FOREIGN KEY service_provider_sid_idxfk_5 (ser
|
|||||||
CREATE INDEX account_sid_idx ON speech_credentials (account_sid);
|
CREATE INDEX account_sid_idx ON speech_credentials (account_sid);
|
||||||
ALTER TABLE speech_credentials ADD FOREIGN KEY account_sid_idxfk_8 (account_sid) REFERENCES accounts (account_sid);
|
ALTER TABLE speech_credentials ADD FOREIGN KEY account_sid_idxfk_8 (account_sid) REFERENCES accounts (account_sid);
|
||||||
|
|
||||||
|
CREATE INDEX google_custom_voice_sid_idx ON google_custom_voices (google_custom_voice_sid);
|
||||||
|
CREATE INDEX speech_credential_sid_idx ON google_custom_voices (speech_credential_sid);
|
||||||
|
ALTER TABLE google_custom_voices ADD FOREIGN KEY speech_credential_sid_idxfk (speech_credential_sid) REFERENCES speech_credentials (speech_credential_sid) ON DELETE CASCADE;
|
||||||
|
|
||||||
CREATE INDEX user_sid_idx ON users (user_sid);
|
CREATE INDEX user_sid_idx ON users (user_sid);
|
||||||
CREATE INDEX email_idx ON users (email);
|
CREATE INDEX email_idx ON users (email);
|
||||||
CREATE INDEX phone_idx ON users (phone);
|
CREATE INDEX phone_idx ON users (phone);
|
||||||
@@ -704,4 +738,5 @@ ALTER TABLE accounts ADD FOREIGN KEY queue_event_hook_sid_idxfk (queue_event_hoo
|
|||||||
ALTER TABLE accounts ADD FOREIGN KEY device_calling_application_sid_idxfk (device_calling_application_sid) REFERENCES applications (application_sid);
|
ALTER TABLE accounts ADD FOREIGN KEY device_calling_application_sid_idxfk (device_calling_application_sid) REFERENCES applications (application_sid);
|
||||||
|
|
||||||
ALTER TABLE accounts ADD FOREIGN KEY siprec_hook_sid_idxfk (siprec_hook_sid) REFERENCES applications (application_sid);
|
ALTER TABLE accounts ADD FOREIGN KEY siprec_hook_sid_idxfk (siprec_hook_sid) REFERENCES applications (application_sid);
|
||||||
SET FOREIGN_KEY_CHECKS=1;
|
|
||||||
|
SET FOREIGN_KEY_CHECKS=1;
|
||||||
|
|||||||
Reference in New Issue
Block a user