mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
New command line option '-l' to set the log level
This commit is contained in:
parent
44237c3701
commit
3adda3b6c7
1
HISTORY
1
HISTORY
@ -109,3 +109,4 @@ Video Disk Recorder Revision History
|
|||||||
- There can now be more than one video directory (in case you have several
|
- There can now be more than one video directory (in case you have several
|
||||||
disks).
|
disks).
|
||||||
- Fixed learning key codes for PC keyboard.
|
- Fixed learning key codes for PC keyboard.
|
||||||
|
- New command line option '-l' to set the log level.
|
||||||
|
8
dvbapi.c
8
dvbapi.c
@ -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: dvbapi.c 1.16 2000/07/29 14:49:46 kls Exp $
|
* $Id: dvbapi.c 1.17 2000/07/29 19:00:19 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "dvbapi.h"
|
#include "dvbapi.h"
|
||||||
@ -1158,10 +1158,12 @@ bool cDvbApi::Init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PrimaryDvbApi = dvbApi[0];
|
PrimaryDvbApi = dvbApi[0];
|
||||||
if (NumDvbApis > 0)
|
if (NumDvbApis > 0) {
|
||||||
isyslog(LOG_INFO, "found %d video device%s", NumDvbApis, NumDvbApis > 1 ? "s" : "");
|
isyslog(LOG_INFO, "found %d video device%s", NumDvbApis, NumDvbApis > 1 ? "s" : "");
|
||||||
else
|
} // need braces because of isyslog-macro
|
||||||
|
else {
|
||||||
esyslog(LOG_ERR, "ERROR: no video device found, giving up!");
|
esyslog(LOG_ERR, "ERROR: no video device found, giving up!");
|
||||||
|
}
|
||||||
return NumDvbApis > 0;
|
return NumDvbApis > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
tools.c
4
tools.c
@ -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.12 2000/07/29 14:02:41 kls Exp $
|
* $Id: tools.c 1.13 2000/07/29 18:41:45 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
@ -245,7 +245,7 @@ bool RemoveFileOrDir(const char *FileName, bool FollowSymlinks)
|
|||||||
LOG_ERROR_STR(l);
|
LOG_ERROR_STR(l);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
esyslog(LOG_ERR, "symlink name length (%d) exceeded anticipated buffer size (%d)", n, size);
|
esyslog(LOG_ERR, "ERROR: symlink name length (%d) exceeded anticipated buffer size (%d)", n, size);
|
||||||
delete l;
|
delete l;
|
||||||
}
|
}
|
||||||
dsyslog(LOG_INFO, "removing %s", buffer);
|
dsyslog(LOG_INFO, "removing %s", buffer);
|
||||||
|
27
vdr.c
27
vdr.c
@ -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.26 2000/07/29 18:19:12 kls Exp $
|
* $Id: vdr.c 1.27 2000/07/29 19:01:57 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
@ -65,6 +65,7 @@ int main(int argc, char *argv[])
|
|||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{ "daemon", no_argument, NULL, 'd' },
|
{ "daemon", no_argument, NULL, 'd' },
|
||||||
{ "help", no_argument, NULL, 'h' },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
|
{ "log", required_argument, NULL, 'l' },
|
||||||
{ "port", required_argument, NULL, 'p' },
|
{ "port", required_argument, NULL, 'p' },
|
||||||
{ "video", required_argument, NULL, 'v' },
|
{ "video", required_argument, NULL, 'v' },
|
||||||
{ 0 }
|
{ 0 }
|
||||||
@ -72,13 +73,17 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
int c;
|
int c;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
while ((c = getopt_long(argc, argv, "dhp:v:", long_options, &option_index)) != -1) {
|
while ((c = getopt_long(argc, argv, "dhl:p:v:", long_options, &option_index)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'd': DaemonMode = true; break;
|
case 'd': DaemonMode = true; break;
|
||||||
case 'h': printf("Usage: vdr [OPTION]\n\n"
|
case 'h': printf("Usage: vdr [OPTION]\n\n"
|
||||||
" -h, --help display this help and exit\n"
|
" -h, --help display this help and exit\n"
|
||||||
" -d, --daemon run in daemon mode\n"
|
" -d, --daemon run in daemon mode\n"
|
||||||
" -p PORT, --port=PORT use PORT for SVDRP (default: %d, '0' turns off SVDRP)\n"
|
" -l LEVEL, --log=LEVEL set log level (default: 3)\n"
|
||||||
|
" 0 = no logging, 1 = errors only,\n"
|
||||||
|
" 2 = errors and info, 3 = errors, info and debug\n"
|
||||||
|
" -p PORT, --port=PORT use PORT for SVDRP (default: %d)\n"
|
||||||
|
" 0 turns off SVDRP\n"
|
||||||
" -v DIR, --video=DIR use DIR as video directory (default is %s)\n"
|
" -v DIR, --video=DIR use DIR as video directory (default is %s)\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Report bugs to <vdr-bugs@cadsoft.de>\n",
|
"Report bugs to <vdr-bugs@cadsoft.de>\n",
|
||||||
@ -87,8 +92,18 @@ int main(int argc, char *argv[])
|
|||||||
);
|
);
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
|
case 'l': if (isnumber(optarg)) {
|
||||||
|
int l = atoi(optarg);
|
||||||
|
if (0 <= l && l <= 3) {
|
||||||
|
SysLogLevel = l;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf(stderr, "vdr: invalid log level: %s\n", optarg);
|
||||||
|
abort();
|
||||||
|
break;
|
||||||
case 'p': if (isnumber(optarg))
|
case 'p': if (isnumber(optarg))
|
||||||
SVDRPport = strtol(optarg, NULL, 10);
|
SVDRPport = atoi(optarg);
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "vdr: invalid port number: %s\n", optarg);
|
fprintf(stderr, "vdr: invalid port number: %s\n", optarg);
|
||||||
abort();
|
abort();
|
||||||
@ -102,6 +117,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Log file:
|
// Log file:
|
||||||
|
|
||||||
|
if (SysLogLevel > 0)
|
||||||
openlog("vdr", LOG_PID | LOG_CONS, LOG_USER);
|
openlog("vdr", LOG_PID | LOG_CONS, LOG_USER);
|
||||||
|
|
||||||
// Check the video directory:
|
// Check the video directory:
|
||||||
@ -118,7 +134,7 @@ int main(int argc, char *argv[])
|
|||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
fprintf(stderr, "%s\n", strerror(errno));
|
fprintf(stderr, "%s\n", strerror(errno));
|
||||||
esyslog(LOG_ERR, strerror(errno));
|
esyslog(LOG_ERR, "ERROR: %s", strerror(errno));
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
if (pid != 0)
|
if (pid != 0)
|
||||||
@ -255,6 +271,7 @@ int main(int argc, char *argv[])
|
|||||||
delete SVDRP;
|
delete SVDRP;
|
||||||
cDvbApi::Cleanup();
|
cDvbApi::Cleanup();
|
||||||
isyslog(LOG_INFO, "exiting");
|
isyslog(LOG_INFO, "exiting");
|
||||||
|
if (SysLogLevel > 0)
|
||||||
closelog();
|
closelog();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user