| 272 | |
| 273 | |
| 274 | int xlog_2(struct sip_msg* msg, char* lev, char* frm) |
| 275 | { |
| 276 | int log_len, ret; |
| 277 | long level; |
| 278 | xl_level_p xlp; |
| 279 | pv_value_t value; |
| 280 | |
| 281 | xlp = (xl_level_t*)(void*)lev; |
| 282 | if(xlp->type==1) |
| 283 | { |
| 284 | if(pv_get_spec_value(msg, &xlp->v.sp, &value)!=0 |
| 285 | || value.flags&PV_VAL_NULL || !(value.flags&PV_VAL_INT)) |
| 286 | { |
| 287 | LM_ERR("invalid log level value [%d]\n", value.flags); |
| 288 | return -1; |
| 289 | } |
| 290 | level = (long)value.ri; |
| 291 | } else { |
| 292 | level = xlp->v.level; |
| 293 | } |
| 294 | |
| 295 | if(!is_xlog_printable((int)level)) |
| 296 | return 1; |
| 297 | |
| 298 | log_len = xlog_buf_size; |
| 299 | |
| 300 | ret = xl_print_log(msg, (pv_elem_t*)(void*)frm, &log_len); |
| 301 | if (ret == -1) { |
| 302 | LM_ERR("global print buffer too small, increase 'xlog_buf_size'\n"); |
| 303 | return -1; |
| 304 | } |
| 305 | |
| 306 | /* set the xlog as log level to trick "LM_GEN" */ |
| 307 | set_proc_log_level( *xlog_level ); |
| 308 | |
| 309 | /* log_buf[log_len] = '\0'; */ |
| 310 | LM_GEN1((int)level, "%.*s", log_len, log_buf); |
| 311 | |
| 312 | reset_proc_log_level(); |
| 313 | |
| 314 | return ret; |
| 315 | } |
| 316 | |
| 317 | |
| 318 | int xlog_1(struct sip_msg* msg, char* frm) |
no test coverage detected