Commit 81cbec21 authored by Christophe Massiot's avatar Christophe Massiot

add -l option for syslog logging

parent 41c95b65
/***************************************************************************** /*****************************************************************************
* aggregartp.c: split an RTP stream for several contribution links * aggregartp.c: split an RTP stream for several contribution links
***************************************************************************** *****************************************************************************
* Copyright (C) 2009, 2011, 2014 VideoLAN * Copyright (C) 2009, 2011, 2014-2015 VideoLAN
* $Id$ * $Id$
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <pthread.h> #include <pthread.h>
#include <poll.h> #include <poll.h>
#include <syslog.h>
#include <bitstream/ietf/rtp.h> #include <bitstream/ietf/rtp.h>
...@@ -84,7 +85,7 @@ static uint64_t i_retx_buffer = DEFAULT_RETX_BUFFER * 27000; ...@@ -84,7 +85,7 @@ static uint64_t i_retx_buffer = DEFAULT_RETX_BUFFER * 27000;
static void usage(void) static void usage(void)
{ {
msg_Raw( NULL, "Usage: aggregartp [-i <RT priority>] [-t <ttl>] [-w] [-o <SSRC IP>] [-U] [-x <retx buffer>] [-X <retx URL>] [-m <payload size>] [-R <RTP header>] @<src host> <dest host 1>[,<weight 1>] ... [<dest host N>,<weight N>]" ); msg_Raw( NULL, "Usage: aggregartp [-i <RT priority>] [-l <syslogtag>] [-t <ttl>] [-w] [-o <SSRC IP>] [-U] [-x <retx buffer>] [-X <retx URL>] [-m <payload size>] [-R <RTP header>] @<src host> <dest host 1>[,<weight 1>] ... [<dest host N>,<weight N>]" );
msg_Raw( NULL, " host format: [<connect addr>[:<connect port>]][@[<bind addr][:<bind port>]]" ); msg_Raw( NULL, " host format: [<connect addr>[:<connect port>]][@[<bind addr][:<bind port>]]" );
msg_Raw( NULL, " -w: overwrite RTP timestamps" ); msg_Raw( NULL, " -w: overwrite RTP timestamps" );
msg_Raw( NULL, " -o: overwrite RTP SSRC" ); msg_Raw( NULL, " -o: overwrite RTP SSRC" );
...@@ -249,6 +250,7 @@ int main( int i_argc, char **pp_argv ) ...@@ -249,6 +250,7 @@ int main( int i_argc, char **pp_argv )
{ {
int c; int c;
int i_priority = -1; int i_priority = -1;
const char *psz_syslog_tag = NULL;
int i_ttl = 0; int i_ttl = 0;
bool b_udp = false; bool b_udp = false;
struct pollfd *pfd = malloc(sizeof(struct pollfd)); struct pollfd *pfd = malloc(sizeof(struct pollfd));
...@@ -260,7 +262,7 @@ int main( int i_argc, char **pp_argv ) ...@@ -260,7 +262,7 @@ int main( int i_argc, char **pp_argv )
pfd[i_nb_retx - 1].fd = i_fd; \ pfd[i_nb_retx - 1].fd = i_fd; \
pfd[i_nb_retx - 1].events = POLLIN; pfd[i_nb_retx - 1].events = POLLIN;
while ( (c = getopt( i_argc, pp_argv, "i:t:wo:x:X:Um:R:h" )) != -1 ) while ( (c = getopt( i_argc, pp_argv, "i:l:t:wo:x:X:Um:R:h" )) != -1 )
{ {
switch ( c ) switch ( c )
{ {
...@@ -268,6 +270,10 @@ int main( int i_argc, char **pp_argv ) ...@@ -268,6 +270,10 @@ int main( int i_argc, char **pp_argv )
i_priority = strtol( optarg, NULL, 0 ); i_priority = strtol( optarg, NULL, 0 );
break; break;
case 'l':
psz_syslog_tag = optarg;
break;
case 't': case 't':
i_ttl = strtol( optarg, NULL, 0 ); i_ttl = strtol( optarg, NULL, 0 );
break; break;
...@@ -326,6 +332,9 @@ int main( int i_argc, char **pp_argv ) ...@@ -326,6 +332,9 @@ int main( int i_argc, char **pp_argv )
if ( optind >= i_argc - 1 ) if ( optind >= i_argc - 1 )
usage(); usage();
if ( psz_syslog_tag != NULL )
msg_Openlog( psz_syslog_tag, LOG_NDELAY, LOG_USER );
i_input_fd = OpenSocket( pp_argv[optind], 0, DEFAULT_PORT, 0, NULL, i_input_fd = OpenSocket( pp_argv[optind], 0, DEFAULT_PORT, 0, NULL,
&b_input_tcp, NULL ); &b_input_tcp, NULL );
if ( i_input_fd == -1 ) if ( i_input_fd == -1 )
...@@ -490,6 +499,8 @@ int main( int i_argc, char **pp_argv ) ...@@ -490,6 +499,8 @@ int main( int i_argc, char **pp_argv )
} }
} }
if ( psz_syslog_tag != NULL )
msg_Closelog();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
* ingests.c: create the aux file for a transport stream file * ingests.c: create the aux file for a transport stream file
***************************************************************************** *****************************************************************************
* Copyright (C) 2009, 2011 VideoLAN * Copyright (C) 2009, 2011, 2015 VideoLAN
* $Id$ * $Id$
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <syslog.h>
#include <bitstream/mpeg/ts.h> #include <bitstream/mpeg/ts.h>
...@@ -59,7 +60,7 @@ static uint64_t i_last_stc = 0; ...@@ -59,7 +60,7 @@ static uint64_t i_last_stc = 0;
static void usage(void) static void usage(void)
{ {
msg_Raw( NULL, "Usage: ingests -p <PCR PID> [-m <payload size>] <input ts>" ); msg_Raw( NULL, "Usage: ingests [-l <syslogtag>] -p <PCR PID> [-m <payload size>] <input ts>" );
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -184,6 +185,7 @@ static void TSHandle( uint8_t *p_ts ) ...@@ -184,6 +185,7 @@ static void TSHandle( uint8_t *p_ts )
*****************************************************************************/ *****************************************************************************/
int main( int i_argc, char **pp_argv ) int main( int i_argc, char **pp_argv )
{ {
const char *psz_syslog_tag = NULL;
uint8_t *p_buffer; uint8_t *p_buffer;
unsigned int i_payload_size = DEFAULT_PAYLOAD_SIZE; unsigned int i_payload_size = DEFAULT_PAYLOAD_SIZE;
mode_t i_mode; mode_t i_mode;
...@@ -192,11 +194,15 @@ int main( int i_argc, char **pp_argv ) ...@@ -192,11 +194,15 @@ int main( int i_argc, char **pp_argv )
{ {
int c; int c;
if ( (c = getopt(i_argc, pp_argv, "p:m:h")) == -1 ) if ( (c = getopt(i_argc, pp_argv, "l:p:m:h")) == -1 )
break; break;
switch ( c ) switch ( c )
{ {
case 'l':
psz_syslog_tag = optarg;
break;
case 'p': case 'p':
i_pcr_pid = strtoul(optarg, NULL, 0); i_pcr_pid = strtoul(optarg, NULL, 0);
break; break;
...@@ -220,6 +226,9 @@ int main( int i_argc, char **pp_argv ) ...@@ -220,6 +226,9 @@ int main( int i_argc, char **pp_argv )
if ( optind >= i_argc || !i_pcr_pid ) if ( optind >= i_argc || !i_pcr_pid )
usage(); usage();
if ( psz_syslog_tag != NULL )
msg_Openlog( psz_syslog_tag, LOG_NDELAY, LOG_USER );
i_mode = StatFile( pp_argv[optind] ); i_mode = StatFile( pp_argv[optind] );
if ( S_ISCHR( i_mode ) || S_ISFIFO( i_mode ) || S_ISDIR( i_mode ) ) if ( S_ISCHR( i_mode ) || S_ISFIFO( i_mode ) || S_ISDIR( i_mode ) )
usage(); usage();
...@@ -262,6 +271,9 @@ int main( int i_argc, char **pp_argv ) ...@@ -262,6 +271,9 @@ int main( int i_argc, char **pp_argv )
fclose( p_output_aux ); fclose( p_output_aux );
close( i_fd ); close( i_fd );
if ( psz_syslog_tag != NULL )
msg_Closelog();
return 0; return 0;
} }
/***************************************************************************** /*****************************************************************************
* multicat.c: netcat-equivalent for multicast * multicat.c: netcat-equivalent for multicast
***************************************************************************** *****************************************************************************
* Copyright (C) 2009, 2011-2012 VideoLAN * Copyright (C) 2009, 2011-2012, 2015 VideoLAN
* $Id$ * $Id$
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <pthread.h> #include <pthread.h>
#include <poll.h> #include <poll.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <syslog.h>
#ifdef SIOCGSTAMPNS #ifdef SIOCGSTAMPNS
# define HAVE_TIMESTAMPS # define HAVE_TIMESTAMPS
...@@ -93,7 +94,7 @@ void (*pf_ExitWrite)(void); ...@@ -93,7 +94,7 @@ void (*pf_ExitWrite)(void);
static void usage(void) static void usage(void)
{ {
msg_Raw( NULL, "Usage: multicat [-i <RT priority>] [-t <ttl>] [-X] [-T <file name>] [-f] [-p <PCR PID>] [-s <chunks>] [-n <chunks>] [-k <start time>] [-d <duration>] [-a] [-r <file duration>] [-S <SSRC IP>] [-u] [-U] [-m <payload size>] [-R <RTP header size>] [-w] <input item> <output item>" ); msg_Raw( NULL, "Usage: multicat [-i <RT priority>] [-l <syslogtag>] [-t <ttl>] [-X] [-T <file name>] [-f] [-p <PCR PID>] [-s <chunks>] [-n <chunks>] [-k <start time>] [-d <duration>] [-a] [-r <file duration>] [-S <SSRC IP>] [-u] [-U] [-m <payload size>] [-R <RTP header size>] [-w] <input item> <output item>" );
msg_Raw( NULL, " item format: <file path | device path | FIFO path | directory path | network host>" ); msg_Raw( NULL, " item format: <file path | device path | FIFO path | directory path | network host>" );
msg_Raw( NULL, " host format: [<connect addr>[:<connect port>]][@[<bind addr][:<bind port>]]" ); msg_Raw( NULL, " host format: [<connect addr>[:<connect port>]][@[<bind addr][:<bind port>]]" );
msg_Raw( NULL, " -X: also pass-through all packets to stdout" ); msg_Raw( NULL, " -X: also pass-through all packets to stdout" );
...@@ -762,6 +763,7 @@ static void GetPCR( const uint8_t *p_buffer, size_t i_read_size ) ...@@ -762,6 +763,7 @@ static void GetPCR( const uint8_t *p_buffer, size_t i_read_size )
int main( int i_argc, char **pp_argv ) int main( int i_argc, char **pp_argv )
{ {
int i_priority = -1; int i_priority = -1;
const char *psz_syslog_tag = NULL;
bool b_passthrough = false; bool b_passthrough = false;
int i_stc_fd = -1; int i_stc_fd = -1;
off_t i_skip_chunks = 0, i_nb_chunks = -1; off_t i_skip_chunks = 0, i_nb_chunks = -1;
...@@ -775,7 +777,7 @@ int main( int i_argc, char **pp_argv ) ...@@ -775,7 +777,7 @@ int main( int i_argc, char **pp_argv )
sigset_t set; sigset_t set;
/* Parse options */ /* Parse options */
while ( (c = getopt( i_argc, pp_argv, "i:t:XT:fp:s:n:k:d:ar:S:uUm:R:wh" )) != -1 ) while ( (c = getopt( i_argc, pp_argv, "i:l:t:XT:fp:s:n:k:d:ar:S:uUm:R:wh" )) != -1 )
{ {
switch ( c ) switch ( c )
{ {
...@@ -783,6 +785,10 @@ int main( int i_argc, char **pp_argv ) ...@@ -783,6 +785,10 @@ int main( int i_argc, char **pp_argv )
i_priority = strtol( optarg, NULL, 0 ); i_priority = strtol( optarg, NULL, 0 );
break; break;
case 'l':
psz_syslog_tag = optarg;
break;
case 't': case 't':
i_ttl = strtol( optarg, NULL, 0 ); i_ttl = strtol( optarg, NULL, 0 );
break; break;
...@@ -869,6 +875,9 @@ int main( int i_argc, char **pp_argv ) ...@@ -869,6 +875,9 @@ int main( int i_argc, char **pp_argv )
if ( optind >= i_argc - 1 ) if ( optind >= i_argc - 1 )
usage(); usage();
if ( psz_syslog_tag != NULL )
msg_Openlog( psz_syslog_tag, LOG_NDELAY, LOG_USER );
/* Open sockets */ /* Open sockets */
if ( udp_InitRead( pp_argv[optind], i_asked_payload_size, i_skip_chunks, if ( udp_InitRead( pp_argv[optind], i_asked_payload_size, i_skip_chunks,
i_seek ) < 0 ) i_seek ) < 0 )
...@@ -1087,6 +1096,8 @@ dropped_packet: ...@@ -1087,6 +1096,8 @@ dropped_packet:
pf_ExitRead(); pf_ExitRead();
pf_ExitWrite(); pf_ExitWrite();
if ( psz_syslog_tag != NULL )
msg_Closelog();
return b_error ? EXIT_FAILURE : EXIT_SUCCESS; return b_error ? EXIT_FAILURE : EXIT_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
* multicat_validate.c: validate position in directory input * multicat_validate.c: validate position in directory input
***************************************************************************** *****************************************************************************
* Copyright (C) 2009, 2011 VideoLAN * Copyright (C) 2009, 2011, 2015 VideoLAN
* $Id$ * $Id$
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <inttypes.h> #include <inttypes.h>
#include <string.h> #include <string.h>
#include <syslog.h>
#include "util.h" #include "util.h"
...@@ -49,7 +50,7 @@ static bool b_status = false; ...@@ -49,7 +50,7 @@ static bool b_status = false;
static void usage(void) static void usage(void)
{ {
msg_Raw( NULL, "Usage: multicat_validate [-k <start time>] [-r <file duration>] [-W <tolerance>] [-m <payload size>] <input directory>" ); msg_Raw( NULL, "Usage: multicat_validate [-l <syslogtag>] [-k <start time>] [-r <file duration>] [-W <tolerance>] [-m <payload size>] <input directory>" );
msg_Raw( NULL, " -k: start at the given position (in 27 MHz units, negative = from the end)" ); msg_Raw( NULL, " -k: start at the given position (in 27 MHz units, negative = from the end)" );
msg_Raw( NULL, " -r: in directory mode, rotate file after this duration (default: 97200000000 ticks = 1 hour)" ); msg_Raw( NULL, " -r: in directory mode, rotate file after this duration (default: 97200000000 ticks = 1 hour)" );
msg_Raw( NULL, " -W: maximum tolerated wait time before the forthcoming packet (by default: 27000000 ticks = 1 second)" ); msg_Raw( NULL, " -W: maximum tolerated wait time before the forthcoming packet (by default: 27000000 ticks = 1 second)" );
...@@ -97,6 +98,7 @@ retry: ...@@ -97,6 +98,7 @@ retry:
*****************************************************************************/ *****************************************************************************/
int main( int i_argc, char **pp_argv ) int main( int i_argc, char **pp_argv )
{ {
const char *psz_syslog_tag = NULL;
off_t i_nb_skipped_chunks; off_t i_nb_skipped_chunks;
FILE *p_input_aux; FILE *p_input_aux;
int c; int c;
...@@ -104,10 +106,14 @@ int main( int i_argc, char **pp_argv ) ...@@ -104,10 +106,14 @@ int main( int i_argc, char **pp_argv )
setvbuf(stdout, NULL, _IOLBF, 0); setvbuf(stdout, NULL, _IOLBF, 0);
while ( (c = getopt( i_argc, pp_argv, "k:r:W:m:h" )) != -1 ) while ( (c = getopt( i_argc, pp_argv, "l:k:r:W:m:h" )) != -1 )
{ {
switch ( c ) switch ( c )
{ {
case 'l':
psz_syslog_tag = optarg;
break;
case 'k': case 'k':
i_delay = strtoull( optarg, NULL, 0 ); i_delay = strtoull( optarg, NULL, 0 );
break; break;
...@@ -135,6 +141,9 @@ int main( int i_argc, char **pp_argv ) ...@@ -135,6 +141,9 @@ int main( int i_argc, char **pp_argv )
psz_dir_name = pp_argv[optind]; psz_dir_name = pp_argv[optind];
printf( "0\n" ); printf( "0\n" );
if ( psz_syslog_tag != NULL )
msg_Openlog( psz_syslog_tag, LOG_NDELAY, LOG_USER );
if ( i_delay <= 0 ) if ( i_delay <= 0 )
{ {
i_delay *= -1; i_delay *= -1;
...@@ -196,4 +205,7 @@ int main( int i_argc, char **pp_argv ) ...@@ -196,4 +205,7 @@ int main( int i_argc, char **pp_argv )
HandleSTC( i_stc ); HandleSTC( i_stc );
} }
if ( psz_syslog_tag != NULL )
msg_Closelog();
} }
/***************************************************************************** /*****************************************************************************
* reordertp.c: rebuild an RTP stream from several aggregated links * reordertp.c: rebuild an RTP stream from several aggregated links
***************************************************************************** *****************************************************************************
* Copyright (C) 2009, 2011, 2014 VideoLAN * Copyright (C) 2009, 2011, 2014-2015 VideoLAN
* $Id$ * $Id$
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <pthread.h> #include <pthread.h>
#include <poll.h> #include <poll.h>
#include <syslog.h>
#include <bitstream/ietf/rtp.h> #include <bitstream/ietf/rtp.h>
...@@ -113,7 +114,7 @@ static int i_last_retx_input = 0; ...@@ -113,7 +114,7 @@ static int i_last_retx_input = 0;
static void usage(void) static void usage(void)
{ {
msg_Raw( NULL, "Usage: reordertp [-i <RT priority>] [-t <ttl>] [-b <buffer length>] [-U] [-g <max gap>] [-j <max jitter>] [-r <# of clock ref>] [-n <max retx burst>] [-x <reorder/retx delay>] [-X <retx URL>] [-m <payload size>] [-R <RTP header>] <src host 1> ... [<src host N>] <dest host>" ); msg_Raw( NULL, "Usage: reordertp [-i <RT priority>] [-l <syslogtag>] [-t <ttl>] [-b <buffer length>] [-U] [-g <max gap>] [-j <max jitter>] [-r <# of clock ref>] [-n <max retx burst>] [-x <reorder/retx delay>] [-X <retx URL>] [-m <payload size>] [-R <RTP header>] <src host 1> ... [<src host N>] <dest host>" );
msg_Raw( NULL, " host format: [<connect addr>[:<connect port>]][@[<bind addr][:<bind port>]]" ); msg_Raw( NULL, " host format: [<connect addr>[:<connect port>]][@[<bind addr][:<bind port>]]" );
msg_Raw( NULL, " -U: strip RTP header" ); msg_Raw( NULL, " -U: strip RTP header" );
msg_Raw( NULL, " -b: buffer length in ms [default 400]" ); msg_Raw( NULL, " -b: buffer length in ms [default 400]" );
...@@ -439,6 +440,7 @@ int main( int i_argc, char **pp_argv ) ...@@ -439,6 +440,7 @@ int main( int i_argc, char **pp_argv )
{ {
int i, c; int i, c;
int i_priority = -1; int i_priority = -1;
const char *psz_syslog_tag = NULL;
int i_ttl = 0; int i_ttl = 0;
struct pollfd *pfd = NULL; struct pollfd *pfd = NULL;
int i_fd; int i_fd;
...@@ -454,7 +456,7 @@ int main( int i_argc, char **pp_argv ) ...@@ -454,7 +456,7 @@ int main( int i_argc, char **pp_argv )
pfd[i_nb_inputs - 1].fd = i_fd; \ pfd[i_nb_inputs - 1].fd = i_fd; \
pfd[i_nb_inputs - 1].events = POLLIN | POLLERR | POLLRDHUP | POLLHUP; pfd[i_nb_inputs - 1].events = POLLIN | POLLERR | POLLRDHUP | POLLHUP;
while ( (c = getopt( i_argc, pp_argv, "i:t:b:g:j:r:n:x:X:Um:R:h" )) != -1 ) while ( (c = getopt( i_argc, pp_argv, "i:l:t:b:g:j:r:n:x:X:Um:R:h" )) != -1 )
{ {
switch ( c ) switch ( c )
{ {
...@@ -462,6 +464,10 @@ int main( int i_argc, char **pp_argv ) ...@@ -462,6 +464,10 @@ int main( int i_argc, char **pp_argv )
i_priority = strtol( optarg, NULL, 0 ); i_priority = strtol( optarg, NULL, 0 );
break; break;
case 'l':
psz_syslog_tag = optarg;
break;
case 't': case 't':
i_ttl = strtol( optarg, NULL, 0 ); i_ttl = strtol( optarg, NULL, 0 );
break; break;
...@@ -522,6 +528,9 @@ int main( int i_argc, char **pp_argv ) ...@@ -522,6 +528,9 @@ int main( int i_argc, char **pp_argv )
if ( optind >= i_argc - 1 ) if ( optind >= i_argc - 1 )
usage(); usage();
if ( psz_syslog_tag != NULL )
msg_Openlog( psz_syslog_tag, LOG_NDELAY, LOG_USER );
while ( optind < i_argc - 1 ) while ( optind < i_argc - 1 )
{ {
i_fd = OpenSocket( pp_argv[optind], 0, DEFAULT_PORT, 0, NULL, i_fd = OpenSocket( pp_argv[optind], 0, DEFAULT_PORT, 0, NULL,
...@@ -656,6 +665,9 @@ int main( int i_argc, char **pp_argv ) ...@@ -656,6 +665,9 @@ int main( int i_argc, char **pp_argv )
} }
} }
if ( psz_syslog_tag != NULL )
msg_Closelog();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
* util.c: Utils for the multicat suite * util.c: Utils for the multicat suite
***************************************************************************** *****************************************************************************
* Copyright (C) 2004, 2009, 2011 VideoLAN * Copyright (C) 2004, 2009, 2011, 2015 VideoLAN
* $Id$ * $Id$
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <unistd.h> #include <unistd.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <netdb.h> #include <netdb.h>
#include <syslog.h>
#include "util.h" #include "util.h"
...@@ -55,6 +56,25 @@ ...@@ -55,6 +56,25 @@
#define PSZ_TS_EXT "ts" #define PSZ_TS_EXT "ts"
int i_verbose = VERB_DBG; int i_verbose = VERB_DBG;
static int b_syslog = 0;
/*****************************************************************************
* msg_Openlog
*****************************************************************************/
void msg_Openlog( const char *ident, int option, int facility )
{
openlog(ident, option, facility);
b_syslog = 1;
}
/*****************************************************************************
* msg_Closelog
*****************************************************************************/
void msg_Closelog( void )
{
closelog();
b_syslog = 0;
}
/***************************************************************************** /*****************************************************************************
* msg_Info * msg_Info
...@@ -62,14 +82,23 @@ int i_verbose = VERB_DBG; ...@@ -62,14 +82,23 @@ int i_verbose = VERB_DBG;
void msg_Info( void *_unused, const char *psz_format, ... ) void msg_Info( void *_unused, const char *psz_format, ... )
{ {
if ( i_verbose >= VERB_INFO ) if ( i_verbose >= VERB_INFO )
return;
va_list args;
va_start( args, psz_format );
if ( !b_syslog )
{ {
va_list args;
char psz_fmt[MAX_MSG]; char psz_fmt[MAX_MSG];
va_start( args, psz_format );
snprintf( psz_fmt, MAX_MSG, "info: %s\n", psz_format ); snprintf( psz_fmt, MAX_MSG, "info: %s\n", psz_format );
vfprintf( stderr, psz_fmt, args ); vfprintf( stderr, psz_fmt, args );
} }
else
{
vsyslog( LOG_INFO, psz_format, args );
}
va_end( args );
} }
/***************************************************************************** /*****************************************************************************
...@@ -78,11 +107,20 @@ void msg_Info( void *_unused, const char *psz_format, ... ) ...@@ -78,11 +107,20 @@ void msg_Info( void *_unused, const char *psz_format, ... )
void msg_Err( void *_unused, const char *psz_format, ... ) void msg_Err( void *_unused, const char *psz_format, ... )
{ {
va_list args; va_list args;
char psz_fmt[MAX_MSG];
va_start( args, psz_format ); va_start( args, psz_format );
snprintf( psz_fmt, MAX_MSG, "error: %s\n", psz_format ); if ( !b_syslog )
vfprintf( stderr, psz_fmt, args ); {
char psz_fmt[MAX_MSG];
snprintf( psz_fmt, MAX_MSG, "error: %s\n", psz_format );
vfprintf( stderr, psz_fmt, args );
}
else
{
vsyslog( LOG_ERR, psz_format, args );
}
va_end( args );
} }
/***************************************************************************** /*****************************************************************************
...@@ -91,14 +129,23 @@ void msg_Err( void *_unused, const char *psz_format, ... ) ...@@ -91,14 +129,23 @@ void msg_Err( void *_unused, const char *psz_format, ... )