Module: sip-router
Branch: master
Commit: e01ed4b2eebff83849fc838f265c5d12927b5e13
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e01ed4b…
Author: Elena-Ramona Modroiu <ramona(a)rosdev.ro>
Committer: Elena-Ramona Modroiu <ramona(a)rosdev.ro>
Date: Tue Feb 2 15:45:58 2010 +0100
xlog(k): parameter to control printing cfg name
- long_format set to 1 makes xlogl() and xdbgl() to print config file
name before line number (useful for usage of 'include_file')
---
modules_k/xlog/README | 36 ++++++++++++++++++++++++++----------
modules_k/xlog/doc/xlog_admin.xml | 20 ++++++++++++++++++++
modules_k/xlog/xlog.c | 12 ++++++++++--
3 files changed, 56 insertions(+), 12 deletions(-)
diff --git a/modules_k/xlog/README b/modules_k/xlog/README
index d7a1a61..6c02463 100644
--- a/modules_k/xlog/README
+++ b/modules_k/xlog/README
@@ -33,7 +33,8 @@ Elena-Ramona Modroiu
4.1. buf_size (integer)
4.2. force_color (integer)
- 4.3. prefix (str)
+ 4.3. long_format (integer)
+ 4.4. prefix (str)
5. Exported Functions
@@ -46,9 +47,10 @@ Elena-Ramona Modroiu
1.1. Set buf_size parameter
1.2. Set force_color parameter
- 1.3. Set prefix parameter
- 1.4. xlog usage
- 1.5. xdbg usage
+ 1.3. Set long_format parameter
+ 1.4. Set prefix parameter
+ 1.5. xlog usage
+ 1.6. xdbg usage
Chapter 1. Admin Guide
@@ -65,7 +67,8 @@ Chapter 1. Admin Guide
4.1. buf_size (integer)
4.2. force_color (integer)
- 4.3. prefix (str)
+ 4.3. long_format (integer)
+ 4.4. prefix (str)
5. Exported Functions
@@ -119,7 +122,8 @@ Chapter 1. Admin Guide
4.1. buf_size (integer)
4.2. force_color (integer)
- 4.3. prefix (str)
+ 4.3. long_format (integer)
+ 4.4. prefix (str)
4.1. buf_size (integer)
@@ -143,13 +147,25 @@ modparam("xlog", "buf_size", 8192)
modparam("xlog", "force_color", 0)
...
-4.3. prefix (str)
+4.3. long_format (integer)
+
+ When set to 1, prints config file name in xlogl() and xdbgl() before
+ line number.
+
+ Default value is 0.
+
+ Example 1.3. Set long_format parameter
+...
+modparam("xlog", "long_format", 1)
+...
+
+4.4. prefix (str)
Prefix to be printed before the log message.
Default value is "<script>: ".
- Example 1.3. Set prefix parameter
+ Example 1.4. Set prefix parameter
...
modparam("xlog", "prefix", "-xlog: ")
...
@@ -185,7 +201,7 @@ modparam("xlog", "prefix", "-xlog: ")
This function can be used from ANY_ROUTE.
- Example 1.4. xlog usage
+ Example 1.5. xlog usage
...
xlog("L_ERR", "time [$Tf] method ($rm) r-uri ($ru) 2nd via
($hdr(via[1]))\n");
...
@@ -204,7 +220,7 @@ xlog("$var(loglevel)", "time [$Tf] method ($rm) r-uri
($ru)\n");
This function can be used from ANY_ROUTE.
- Example 1.5. xdbg usage
+ Example 1.6. xdbg usage
...
xdbg("time $Cbx[$Tf]$Cxx method ($rm) r-uri ($ru)\n");
...
diff --git a/modules_k/xlog/doc/xlog_admin.xml b/modules_k/xlog/doc/xlog_admin.xml
index f9949de..683d110 100644
--- a/modules_k/xlog/doc/xlog_admin.xml
+++ b/modules_k/xlog/doc/xlog_admin.xml
@@ -132,6 +132,26 @@ modparam("xlog", "force_color", 0)
</example>
</section>
<section>
+ <title><varname>long_format</varname> (integer)</title>
+ <para>
+ When set to 1, prints config file name in xlogl() and xdbgl()
+ before line number.
+ </para>
+ <para>
+ <emphasis>
+ Default value is 0.
+ </emphasis>
+ </para>
+ <example>
+ <title>Set <varname>long_format</varname> parameter</title>
+ <programlisting format="linespecific">
+...
+modparam("xlog", "long_format", 1)
+...
+</programlisting>
+ </example>
+ </section>
+ <section>
<title><varname>prefix</varname> (str)</title>
<para>
Prefix to be printed before the log message.
diff --git a/modules_k/xlog/xlog.c b/modules_k/xlog/xlog.c
index 67cc913..d626b0a 100644
--- a/modules_k/xlog/xlog.c
+++ b/modules_k/xlog/xlog.c
@@ -48,6 +48,7 @@ char *_xlog_prefix = "<script>: ";
/** parameters */
static int buf_size=4096;
static int force_color=0;
+static int long_format=0;
/** module functions */
static int mod_init(void);
@@ -107,6 +108,7 @@ static cmd_export_t cmds[]={
static param_export_t params[]={
{"buf_size", INT_PARAM, &buf_size},
{"force_color", INT_PARAM, &force_color},
+ {"long_format", INT_PARAM, &long_format},
{"prefix", STR_PARAM, &_xlog_prefix},
{0,0,0}
};
@@ -153,8 +155,14 @@ static inline int xlog_helper(struct sip_msg* msg, xl_msg_t *xm,
return -1;
txt.s = _xlog_buf;
if(line>0)
- LOG_(DEFAULT_FACILITY, level, _xlog_prefix,
- "%d:%.*s", (xm->a)?xm->a->cline:0, txt.len, txt.s);
+ if(long_format==1)
+ LOG_(DEFAULT_FACILITY, level, _xlog_prefix,
+ "%s:%d:%.*s",
+ (xm->a)?(((xm->a->cfile)?xm->a->cfile:"")):"",
+ (xm->a)?xm->a->cline:0, txt.len, txt.s);
+ else
+ LOG_(DEFAULT_FACILITY, level, _xlog_prefix,
+ "%d:%.*s", (xm->a)?xm->a->cline:0, txt.len, txt.s);
else
LOG_(DEFAULT_FACILITY, level, _xlog_prefix,
"%.*s", txt.len, txt.s);