[sr-dev] git:master: core: added log_name config parameter
Daniel-Constantin Mierla
miconda at gmail.com
Thu Aug 20 10:33:37 CEST 2009
On 20.08.2009 11:31 Uhr, Klaus Darilion wrote:
> fyi: added to http://sip-router.org/wiki/cookbooks/core-cookbook/devel
thanks!
>
> Daniel-Constantin Mierla schrieb:
>> Module: sip-router
>> Branch: master
>> Commit: 95bf86454e277a7a0ef1c41c2995806f65eda17b
>> URL:
>> http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=95bf86454e277a7a0ef1c41c2995806f65eda17b
>>
>>
>> Author: Daniel-Constantin Mierla <miconda at gmail.com>
>> Committer: Daniel-Constantin Mierla <miconda at gmail.com>
>> Date: Thu Aug 20 10:41:02 2009 +0300
>>
>> core: added log_name config parameter
>>
>> - log_name allows to set app name to be used when printing to syslog
>> - useful to filter log messages when running many instance on same
>> server
>>
>> ---
>>
>> cfg.lex | 2 ++
>> cfg.y | 3 +++
>> dprint.h | 1 +
>> main.c | 4 +++-
>> 4 files changed, 9 insertions(+), 1 deletions(-)
>>
>> diff --git a/cfg.lex b/cfg.lex
>> index a99968d..32aed32 100644
>> --- a/cfg.lex
>> +++ b/cfg.lex
>> @@ -281,6 +281,7 @@ DEBUG debug
>> FORK fork
>> LOGSTDERROR log_stderror
>> LOGFACILITY log_facility
>> +LOGNAME log_name
>> LISTEN listen
>> ALIAS alias
>> SR_AUTO_ALIASES auto_aliases
>> @@ -577,6 +578,7 @@ EAT_ABLE [\ \t\b\r]
>> <INITIAL>{FORK} { count(); yylval.strval=yytext; return FORK; }
>> <INITIAL>{LOGSTDERROR} { yylval.strval=yytext; return LOGSTDERROR; }
>> <INITIAL>{LOGFACILITY} { yylval.strval=yytext; return LOGFACILITY; }
>> +<INITIAL>{LOGNAME} { yylval.strval=yytext; return LOGNAME; }
>> <INITIAL>{LISTEN} { count(); yylval.strval=yytext; return LISTEN; }
>> <INITIAL>{ALIAS} { count(); yylval.strval=yytext; return ALIAS; }
>> <INITIAL>{SR_AUTO_ALIASES} { count(); yylval.strval=yytext;
>> diff --git a/cfg.y b/cfg.y
>> index b51a272..e9e8d8a 100644
>> --- a/cfg.y
>> +++ b/cfg.y
>> @@ -345,6 +345,7 @@ static int case_check_default(struct case_stms*
>> stms);
>> %token FORK
>> %token LOGSTDERROR
>> %token LOGFACILITY
>> +%token LOGNAME
>> %token LISTEN
>> %token ALIAS
>> %token SR_AUTO_ALIASES
>> @@ -758,6 +759,8 @@ assign_stm:
>> default_core_cfg.log_facility=i_tmp;
>> }
>> | LOGFACILITY EQUAL error { yyerror("ID expected"); }
>> + | LOGNAME EQUAL STRING { log_name=$3; }
>> + | LOGNAME EQUAL error { yyerror("string value expected"); }
>> | DNS EQUAL NUMBER { received_dns|= ($3)?DO_DNS:0; }
>> | DNS EQUAL error { yyerror("boolean value expected"); }
>> | REV_DNS EQUAL NUMBER { received_dns|= ($3)?DO_REV_DNS:0; }
>> diff --git a/dprint.h b/dprint.h
>> index 54d47fa..8f9d743 100644
>> --- a/dprint.h
>> +++ b/dprint.h
>> @@ -109,6 +109,7 @@ struct log_level_info {
>>
>> #define is_printable(level) (cfg_get(core, core_cfg, debug)>=(level))
>> extern struct log_level_info log_level_info[];
>> +extern char *log_name;
>>
>> #ifndef NO_SIG_DEBUG
>> /* protection against "simultaneous" printing from signal handlers */
>> diff --git a/main.c b/main.c
>> index 23455e7..9a771f8 100644
>> --- a/main.c
>> +++ b/main.c
>> @@ -321,6 +321,8 @@ int sig_flag = 0; /* last signal
>> received */
>> int dont_fork = 0;
>> int dont_daemonize = 0;
>> int log_stderr = 0;
>> +/* set custom app name for syslog printing */
>> +char *log_name = 0;
>> pid_t creator_pid = (pid_t) -1;
>> int config_check = 0;
>> /* check if reply first via host==us */
>> @@ -2059,7 +2061,7 @@ try_again:
>> #endif /* USE_SCTP */
>> /* init_daemon? */
>> if (!dont_fork){
>> - if ( daemonize(argv[0]) <0 ) goto error;
>> + if ( daemonize((log_name==0)?argv[0]:log_name) <0 ) goto error;
>> }
>> if (install_sigs() != 0){
>> fprintf(stderr, "ERROR: could not install the signal
>> handlers\n");
>>
>>
>> _______________________________________________
>> sr-dev mailing list
>> sr-dev at lists.sip-router.org
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
--
Daniel-Constantin Mierla
* http://www.asipto.com/
More information about the sr-dev
mailing list