Browse code

re.c: logging: convert LOG to LM_*

Ovidiu Sas authored on 04/10/2014 00:56:28
Showing 1 changed files
... ...
@@ -231,16 +231,14 @@ struct subst_expr* subst_parser(str* subst)
231 231
 	cflags=REG_EXTENDED  | REG_NEWLINE; /* don't match newline */
232 232
 	replace_all=0;
233 233
 	if (subst->len<3){
234
-		LOG(L_ERR, "ERROR: subst_parser: expression is too short: %.*s\n",
235
-				subst->len, subst->s);
234
+		LM_ERR("expression is too short: %.*s\n", subst->len, subst->s);
236 235
 		goto error;
237 236
 	}
238 237
 	
239 238
 	p=subst->s;
240 239
 	c=*p;
241 240
 	if (c=='\\'){
242
-		LOG(L_ERR, "ERROR: subst_parser: invalid separator char <%c>"
243
-				" in %.*s\n", c, subst->len, subst->s);
241
+		LM_ERR("invalid separator char <%c> in %.*s\n", c, subst->len, subst->s);
244 242
 		goto error;
245 243
 	}
246 244
 	p++;
... ...
@@ -251,13 +249,12 @@ struct subst_expr* subst_parser(str* subst)
251 249
 		/* if unescaped sep. char */
252 250
 		if ((*p==c) && (*(p-1)!='\\')) goto found_re;
253 251
 	}
254
-	LOG(L_ERR, "ERROR: subst_parser: no separator found: %.*s\n", subst->len, 
255
-			subst->s);
252
+	LM_ERR("no separator found: %.*s\n", subst->len, subst->s);
256 253
 	goto error;
257 254
 found_re:
258 255
 	re_end=p;
259 256
 	if (end < (p + 2)) {
260
-		ERR("subst_parser: String too short\n");
257
+		LM_ERR("String too short\n");
261 258
 		goto error;
262 259
 	}
263 260
 	repl=p+1;
... ...
@@ -279,15 +276,14 @@ found_re:
279 276
 				replace_all=1;
280 277
 				break;
281 278
 			default:
282
-				LOG(L_ERR, "ERROR: subst_parser: unknown flag %c in %.*s\n",
283
-						*p, subst->len, subst->s);
279
+				LM_ERR("unknown flag %c in %.*s\n", *p, subst->len, subst->s);
284 280
 				goto error;
285 281
 		}
286 282
 	}
287 283
 
288 284
 	/* compile the re */
289 285
 	if ((regex=pkg_malloc(sizeof(regex_t)))==0){
290
-		LOG(L_ERR, "ERROR: subst_parser: out of memory (re)\n");
286
+		LM_ERR("out of memory\n");
291 287
 		goto error;
292 288
 	}
293 289
 	c=*re_end; /* regcomp expects null terminated strings -- save */
... ...
@@ -296,8 +292,8 @@ found_re:
296 292
 		pkg_free(regex);
297 293
 		regex=0;
298 294
 		*re_end=c; /* restore */
299
-		LOG(L_ERR, "ERROR: subst_parser: bad regular expression %.*s in "
300
-				"%.*s\n", (int)(re_end-re), re, subst->len, subst->s);
295
+		LM_ERR("bad regular expression %.*s in %.*s\n",
296
+				(int)(re_end-re), re, subst->len, subst->s);
301 297
 		goto error;
302 298
 	}
303 299
 	*re_end=c; /* restore */
... ...
@@ -306,7 +302,7 @@ found_re:
306 302
 					((rw_no)?(rw_no-1)*sizeof(struct replace_with):0));
307 303
 		/* 1 replace_with structure is  already included in subst_expr */
308 304
 	if (se==0){
309
-		LOG(L_ERR, "ERROR: subst_parser: out of memory (subst_expr)\n");
305
+		LM_ERR("out of memory\n");
310 306
 		goto error;
311 307
 	}
312 308
 	memset((void*)se, 0, sizeof(struct subst_expr));
... ...
@@ -314,7 +310,7 @@ found_re:
314 310
 	se->replacement.len=repl_end-repl;
315 311
 	if (se->replacement.len > 0) {
316 312
 		if ((se->replacement.s=pkg_malloc(se->replacement.len))==0){
317
-			LOG(L_ERR, "ERROR: subst_parser: out of memory (replacement)\n");
313
+			LM_ERR("out of memory\n");
318 314
 			goto error;
319 315
 		}
320 316
 		/* start copying */
... ...
@@ -351,7 +347,7 @@ static int replace_build(const char* match, int nmatch, regmatch_t* pmatch,
351 347
 
352 348
 #define RBUF_APPEND(dst, src, size) \
353 349
 	if ((dst) - rbuf + (size) >= REPLACE_BUFFER_SIZE - 1) {	\
354
-		ERR("replace_build: Buffer too small\n");			\
350
+		LM_ERR("Buffer too small\n");			\
355 351
 		goto error;											\
356 352
 	}														\
357 353
 	memcpy((dst), (src), (size));							\
... ...
@@ -383,8 +379,7 @@ static int replace_build(const char* match, int nmatch, regmatch_t* pmatch,
383 379
 				break;
384 380
 			case REPLACE_URI:
385 381
 				if (msg->first_line.type!=SIP_REQUEST){
386
-					LOG(L_CRIT, "BUG: replace_build: uri substitution on"
387
-								" a reply\n");
382
+					LM_CRIT("uri substitution on a reply\n");
388 383
 					break; /* ignore, we can continue */
389 384
 				}
390 385
 				uri= (msg->new_uri.s)?(&msg->new_uri):
... ...
@@ -393,21 +388,20 @@ static int replace_build(const char* match, int nmatch, regmatch_t* pmatch,
393 388
 				break;
394 389
 			case REPLACE_SPEC:
395 390
 				if(pv_get_spec_value(msg, &se->replace[r].u.spec, &sv)!=0) {
396
-					ERR("replace_build: item substitution returned error\n");
391
+					LM_ERR("item substitution returned error\n");
397 392
 					break; /* ignore, we can continue */
398 393
 				}
399 394
 				RBUF_APPEND(dest, sv.rs.s, sv.rs.len);
400 395
 				break;
401 396
 			default:
402
-				LOG(L_CRIT, "BUG: replace_build: unknown type %d\n", 
403
-						se->replace[r].type);
397
+				LM_CRIT("unknown type %d\n", se->replace[r].type);
404 398
 				/* ignore it */
405 399
 		}
406 400
 	}
407 401
 	RBUF_APPEND(dest, p, end-p);
408 402
 	rpl->len = dest - rbuf;
409 403
 	if ((rpl->s = pkg_malloc(rpl->len)) == NULL) {
410
-		ERR("replace_build: Out of pkg memory\n");
404
+		LM_ERR("Out of pkg memory\n");
411 405
 		goto error;
412 406
 	}
413 407
 	memcpy(rpl->s, rbuf, rpl->len);
... ...
@@ -445,7 +439,7 @@ struct replace_lst* subst_run(struct subst_expr* se, const char* input,
445 439
 	/* no of () referenced + 1 for the whole string: pmatch[0] */
446 440
 	pmatch=pkg_malloc(nmatch*sizeof(regmatch_t));
447 441
 	if (pmatch==0){
448
-		LOG(L_ERR, "ERROR: subst_run_ out of mem. (pmatch)\n");
442
+		LM_ERR("out of mem\n");
449 443
 		goto error;
450 444
 	}
451 445
 	eflags=0;
... ...
@@ -455,16 +449,16 @@ struct replace_lst* subst_run(struct subst_expr* se, const char* input,
455 449
 		/* subst */
456 450
 		if (r==0){ /* != REG_NOMATCH */
457 451
 			if (pmatch[0].rm_so==-1) {
458
-				ERR("subst_run: Unknown offset?\n");
452
+				LM_ERR("Unknown offset?\n");
459 453
 				goto error;
460 454
 			}
461 455
 			if (pmatch[0].rm_so==pmatch[0].rm_eo) {
462
-				ERR("subst_run: Matched string is empty, invalid regexp?\n");
456
+				LM_ERR("Matched string is empty, invalid regexp?\n");
463 457
 				goto error;
464 458
 			}
465 459
 			*crt=pkg_malloc(sizeof(struct replace_lst));
466 460
 			if (*crt==0){
467
-				LOG(L_ERR, "ERROR: subst_run: out of mem (crt)\n");
461
+				LM_ERR("out of mem\n");
468 462
 				goto error;
469 463
 			}
470 464
 			memset(*crt, 0, sizeof(struct replace_lst));
... ...
@@ -527,12 +521,12 @@ str* subst_str(const char *input, struct sip_msg* msg, struct subst_expr* se,
527 521
 		len+=(int)(l->rpl.len)-l->size;
528 522
 	res=pkg_malloc(sizeof(str));
529 523
 	if (res==0){
530
-		LOG(L_ERR, "ERROR: subst_str: mem. allocation error\n");
524
+		LM_ERR("mem. allocation error\n");
531 525
 		goto error;
532 526
 	}
533 527
 	res->s=pkg_malloc(len+1); /* space for null termination */
534 528
 	if (res->s==0){
535
-		LOG(L_ERR, "ERROR: subst_str: mem. allocation error (res->s)\n");
529
+		LM_ERR("mem. allocation error (res->s)\n");
536 530
 		goto error;
537 531
 	}
538 532
 	res->s[len]=0;