MCPcopy Create free account
hub / github.com/apache/cassandra-nodejs-driver / getParametersInfo

Function getParametersInfo

lib/tracker/request-logger.js:224–270  ·  view source on GitHub ↗
(params, remaining, maxParameterLength)

Source from the content-addressed store, hash-verified

222}
223
224function getParametersInfo(params, remaining, maxParameterLength) {
225 if (remaining <= 3) {
226 // We need at least 3 chars to describe the parameters
227 // its OK to add more chars in an effort to be descriptive
228 return ' [...]';
229 }
230
231 if (!params) {
232 return ' []';
233 }
234
235 let paramStringifier = (index, length) => formatParam(params[index], length);
236 if (!Array.isArray(params)) {
237 const obj = params;
238 params = Object.keys(params);
239 paramStringifier = (index, length) => {
240 const key = params[index];
241 let result = key.substr(0, length);
242 const rem = length - result.length - 1;
243 if (rem <= 0) {
244 return result;
245 }
246 result += ":" + formatParam(obj[key], rem);
247 return result;
248 };
249 }
250
251 let message = ' [';
252 let i;
253 for (i = 0; remaining > 0 && i < params.length; i++) {
254 if (i > 0) {
255 message += ',';
256 remaining--;
257 }
258
259 const paramString = paramStringifier(i, Math.min(maxParameterLength, remaining));
260 remaining -= paramString.length;
261 message += paramString;
262 }
263
264 if (i < params.length) {
265 message += '...';
266 }
267
268 message += ']';
269 return message;
270}
271
272function formatParam(value, maxLength) {
273 if (value === undefined) {

Callers 2

getStatementInfoFunction · 0.85
getBatchStatementInfoFunction · 0.85

Calls 3

formatParamFunction · 0.85
paramStringifierFunction · 0.85
keysMethod · 0.65

Tested by

no test coverage detected