Extended the '-l' option to allow logging to LOG_LOCALn

This commit is contained in:
Klaus Schmidinger 2002-11-24 15:56:24 +01:00
parent 9544973a10
commit c24dfb7f43
5 changed files with 38 additions and 13 deletions

View File

@ -276,6 +276,7 @@ Hannu Savolainen <hannu@opensound.com>
Jürgen Schmidt <ju@ct.heise.de> Jürgen Schmidt <ju@ct.heise.de>
for fixing a problem with 'in_addr_t' on systems with glibc < 2.2. for fixing a problem with 'in_addr_t' on systems with glibc < 2.2.
for suggesting to optionally allow logging to LOG_LOCALn (n=0..7)
Uwe Freese <mail@uwe-freese.de> Uwe Freese <mail@uwe-freese.de>
for suggesting to automatically close an empty recordings page after deleting for suggesting to automatically close an empty recordings page after deleting

View File

@ -1806,3 +1806,5 @@ Video Disk Recorder Revision History
- Updated 'channels.conf.cable' and made some channels unique using the new RID - Updated 'channels.conf.cable' and made some channels unique using the new RID
(thanks to Andreas Kool for pointing out the problems). (thanks to Andreas Kool for pointing out the problems).
- Made some channels unique in 'channels.conf.terr' using the new RID. - Made some channels unique in 'channels.conf.terr' using the new RID.
- Extended the '-l' option to allow logging to LOG_LOCALn (n=0..7) by writing, for
instance, '-l 3.7' (suggested by Jürgen Schmidt).

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: tools.c 1.73 2002/11/09 15:33:47 kls Exp $ * $Id: tools.c 1.74 2002/11/24 15:47:02 kls Exp $
*/ */
#include "tools.h" #include "tools.h"
@ -235,6 +235,8 @@ void delay_ms(int ms)
bool isnumber(const char *s) bool isnumber(const char *s)
{ {
if (!*s)
return false;
while (*s) { while (*s) {
if (!isdigit(*s)) if (!isdigit(*s))
return false; return false;

4
vdr.1
View File

@ -8,7 +8,7 @@
.\" License as specified in the file COPYING that comes with the .\" License as specified in the file COPYING that comes with the
.\" vdr distribution. .\" vdr distribution.
.\" .\"
.\" $Id: vdr.1 1.4 2002/05/09 16:04:17 kls Exp $ .\" $Id: vdr.1 1.5 2002/11/24 15:52:00 kls Exp $
.\" .\"
.TH vdr 1 "9 May 2002" "1.1.0" "Video Disk Recorder" .TH vdr 1 "9 May 2002" "1.1.0" "Video Disk Recorder"
.SH NAME .SH NAME
@ -67,6 +67,8 @@ Set logging to \fIlevel\fR.
\fB0\fR\ =\ no logging, \fB1\fR\ =\ errors only, \fB0\fR\ =\ no logging, \fB1\fR\ =\ errors only,
\fB2\fR\ =\ errors and info, \fB3\fR\ =\ errors, info and debug. \fB2\fR\ =\ errors and info, \fB3\fR\ =\ errors, info and debug.
The default logging level is \fB3\fR. The default logging level is \fB3\fR.
If logging should be done to LOG_LOCALn instead of
LOG_USER, add '.n' to LEVEL, as in 3.7 (n=0..7).
.TP .TP
.BI -L\ dir ,\ --lib= dir .BI -L\ dir ,\ --lib= dir
Search for plugins in directory \fIdir\fR (default is ./PLUGINS/lib). Search for plugins in directory \fIdir\fR (default is ./PLUGINS/lib).

40
vdr.c
View File

@ -22,7 +22,7 @@
* *
* The project's page is at http://www.cadsoft.de/people/kls/vdr * The project's page is at http://www.cadsoft.de/people/kls/vdr
* *
* $Id: vdr.c 1.133 2002/11/24 10:32:40 kls Exp $ * $Id: vdr.c 1.134 2002/11/24 15:50:16 kls Exp $
*/ */
#include <getopt.h> #include <getopt.h>
@ -93,6 +93,7 @@ int main(int argc, char *argv[])
bool DisplayHelp = false; bool DisplayHelp = false;
bool DisplayVersion = false; bool DisplayVersion = false;
bool DaemonMode = false; bool DaemonMode = false;
int SysLogTarget = LOG_USER;
bool MuteAudio = false; bool MuteAudio = false;
int WatchdogTimeout = DEFAULTWATCHDOG; int WatchdogTimeout = DEFAULTWATCHDOG;
const char *Terminal = NULL; const char *Terminal = NULL;
@ -142,15 +143,31 @@ int main(int argc, char *argv[])
break; break;
case 'h': DisplayHelp = true; case 'h': DisplayHelp = true;
break; break;
case 'l': if (isnumber(optarg)) { case 'l': {
int l = atoi(optarg); char *p = strchr(optarg, '.');
if (0 <= l && l <= 3) { if (p)
SysLogLevel = l; *p = 0;
break; if (isnumber(optarg)) {
} int l = atoi(optarg);
} if (0 <= l && l <= 3) {
SysLogLevel = l;
if (!p)
break;
if (isnumber(p + 1)) {
int l = atoi(optarg);
if (0 <= l && l <= 7) {
int targets[] = { LOG_LOCAL0, LOG_LOCAL1, LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4, LOG_LOCAL5, LOG_LOCAL6, LOG_LOCAL7 };
SysLogTarget = targets[l];
break;
}
}
}
}
if (p)
*p = '.';
fprintf(stderr, "vdr: invalid log level: %s\n", optarg); fprintf(stderr, "vdr: invalid log level: %s\n", optarg);
return 2; return 2;
}
break; break;
case 'L': if (access(optarg, R_OK | X_OK) == 0) case 'L': if (access(optarg, R_OK | X_OK) == 0)
PluginManager.SetDirectory(optarg); PluginManager.SetDirectory(optarg);
@ -182,8 +199,7 @@ int main(int argc, char *argv[])
while (optarg && *optarg && optarg[strlen(optarg) - 1] == '/') while (optarg && *optarg && optarg[strlen(optarg) - 1] == '/')
optarg[strlen(optarg) - 1] = 0; optarg[strlen(optarg) - 1] = 0;
break; break;
case 'w': if (isnumber(optarg)) { case 'w': if (isnumber(optarg)) { int t = atoi(optarg);
int t = atoi(optarg);
if (t >= 0) { if (t >= 0) {
WatchdogTimeout = t; WatchdogTimeout = t;
break; break;
@ -219,6 +235,8 @@ int main(int argc, char *argv[])
" -l LEVEL, --log=LEVEL set log level (default: 3)\n" " -l LEVEL, --log=LEVEL set log level (default: 3)\n"
" 0 = no logging, 1 = errors only,\n" " 0 = no logging, 1 = errors only,\n"
" 2 = errors and info, 3 = errors, info and debug\n" " 2 = errors and info, 3 = errors, info and debug\n"
" if logging should be done to LOG_LOCALn instead of\n"
" LOG_USER, add '.n' to LEVEL, as in 3.7 (n=0..7)\n"
" -L DIR, --lib=DIR search for plugins in DIR (default is %s)\n" " -L DIR, --lib=DIR search for plugins in DIR (default is %s)\n"
" -m, --mute mute audio of the primary DVB device at startup\n" " -m, --mute mute audio of the primary DVB device at startup\n"
" -p PORT, --port=PORT use PORT for SVDRP (default: %d)\n" " -p PORT, --port=PORT use PORT for SVDRP (default: %d)\n"
@ -264,7 +282,7 @@ int main(int argc, char *argv[])
// Log file: // Log file:
if (SysLogLevel > 0) if (SysLogLevel > 0)
openlog("vdr", LOG_PID | LOG_CONS, LOG_USER); openlog("vdr", LOG_PID | LOG_CONS, SysLogTarget);
// Check the video directory: // Check the video directory: