From 84df3081e7e73e4792d55cd15f3478795b31fbf2 Mon Sep 17 00:00:00 2001 From: Quan HL Date: Mon, 7 Oct 2024 16:51:30 +0700 Subject: [PATCH 1/2] support change log level run time --- app.js | 3 +++ lib/middleware.js | 2 ++ test/db/jambones-sql.sql | 8 +++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index bd49cd0..d4f12dc 100644 --- a/app.js +++ b/app.js @@ -287,6 +287,9 @@ if ('test' !== process.env.NODE_ENV) { logger.info(`updating private network cidr from ${srf.locals.privateNetworkCidr} to ${r.private_network_cidr}`); srf.locals.privateNetworkCidr = r.private_network_cidr; } + if (r.log_level) { + logger.level = r.log_level; + } } }, 20000); } diff --git a/lib/middleware.js b/lib/middleware.js index bc92db9..3fcee23 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -235,6 +235,8 @@ module.exports = function(srf, logger) { callId: req.get('Call-ID'), service_provider_sid: req.locals.service_provider_sid, account_sid: req.locals.account_sid + }, { + ...(account.enable_debug_log && {level: 'debug'}) }); next(); diff --git a/test/db/jambones-sql.sql b/test/db/jambones-sql.sql index 19776da..8a9b80a 100644 --- a/test/db/jambones-sql.sql +++ b/test/db/jambones-sql.sql @@ -162,7 +162,7 @@ regex VARCHAR(32) NOT NULL COMMENT 'regex-based pattern match against dialed num description VARCHAR(1024), priority INTEGER NOT NULL COMMENT 'lower priority routes are attempted first', PRIMARY KEY (lcr_route_sid) -) COMMENT='An ordered list of digit patterns in an LCR table. The pat'; +) COMMENT='An ordered list of digit patterns in an LCR table. The patterns are tested in sequence until one matches'; CREATE TABLE lcr ( @@ -173,7 +173,7 @@ default_carrier_set_entry_sid CHAR(36) COMMENT 'default carrier/route to use whe service_provider_sid CHAR(36), account_sid CHAR(36), PRIMARY KEY (lcr_sid) -) COMMENT='An LCR (least cost routing) table that is used by a service '; +) COMMENT='An LCR (least cost routing) table that is used by a service provider or account to make decisions about routing outbound calls when multiple carriers are available.'; CREATE TABLE password_settings ( @@ -359,7 +359,8 @@ CREATE TABLE system_information domain_name VARCHAR(255), sip_domain_name VARCHAR(255), monitoring_domain_name VARCHAR(255), -private_network_cidr VARCHAR(8192) +private_network_cidr VARCHAR(8192), +log_level ENUM('info', 'debug') NOT NULL DEFAULT 'info' ); CREATE TABLE users @@ -553,6 +554,7 @@ siprec_hook_sid CHAR(36), record_all_calls BOOLEAN NOT NULL DEFAULT false, record_format VARCHAR(16) NOT NULL DEFAULT 'mp3', bucket_credential VARCHAR(8192) COMMENT 'credential used to authenticate with storage service', +enable_debug_log BOOLEAN NOT NULL DEFAULT false, PRIMARY KEY (account_sid) ) COMMENT='An enterprise that uses the platform for comm services'; From d3f7d46a8f6448b0cc5165b0faf3889ccf245183 Mon Sep 17 00:00:00 2001 From: Quan HL Date: Mon, 7 Oct 2024 17:22:20 +0700 Subject: [PATCH 2/2] support change log level run time --- lib/middleware.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/middleware.js b/lib/middleware.js index 3fcee23..a3f2789 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -236,7 +236,7 @@ module.exports = function(srf, logger) { service_provider_sid: req.locals.service_provider_sid, account_sid: req.locals.account_sid }, { - ...(account.enable_debug_log && {level: 'debug'}) + ...(req.locals.account.enable_debug_log && {level: 'debug'}) }); next();