mirror of
https://github.com/pygos/init.git
synced 2024-12-22 23:30:50 +01:00
usyslogd: do logfile lookup by facility number
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
This commit is contained in:
parent
f1cc12f55e
commit
8a8f49a501
3 changed files with 6 additions and 4 deletions
|
@ -25,7 +25,7 @@
|
|||
#include "logfile.h"
|
||||
|
||||
|
||||
logfile_t *logfile_create(const char *name)
|
||||
logfile_t *logfile_create(const char *name, int facility)
|
||||
{
|
||||
logfile_t *file;
|
||||
|
||||
|
@ -36,6 +36,7 @@ logfile_t *logfile_create(const char *name)
|
|||
}
|
||||
|
||||
strcpy(file->name, name);
|
||||
file->facility = facility;
|
||||
|
||||
file->fd = open(file->name, O_WRONLY | O_CREAT, 0640);
|
||||
if (file->fd < 0)
|
||||
|
|
|
@ -20,12 +20,13 @@
|
|||
|
||||
typedef struct logfile_t {
|
||||
struct logfile_t *next;
|
||||
int facility;
|
||||
int fd;
|
||||
|
||||
char name[];
|
||||
} logfile_t;
|
||||
|
||||
logfile_t *logfile_create(const char *name);
|
||||
logfile_t *logfile_create(const char *name, int facility);
|
||||
|
||||
void logfile_destroy(logfile_t *file);
|
||||
|
||||
|
|
|
@ -134,12 +134,12 @@ static int print_to_log(const syslog_msg_t *msg)
|
|||
return -1;
|
||||
|
||||
for (log = logfiles; log != NULL; log = log->next) {
|
||||
if (!strcmp(log->name, fac_name))
|
||||
if (log->facility == msg->facility)
|
||||
break;
|
||||
}
|
||||
|
||||
if (log == NULL) {
|
||||
log = logfile_create(fac_name);
|
||||
log = logfile_create(fac_name, msg->facility);
|
||||
if (log == NULL)
|
||||
return -1;
|
||||
log->next = logfiles;
|
||||
|
|
Loading…
Reference in a new issue