mirror of
https://github.com/jorisvink/kore
synced 2025-03-09 04:29:02 -04:00
Add a logfile configuration option.
This will log all output from Kore processes to the specified file.
This commit is contained in:
parent
ff6bae6513
commit
b77d727f72
@ -855,6 +855,7 @@ int kore_connection_accept(struct listener *,
|
||||
|
||||
u_int64_t kore_time_ms(void);
|
||||
void kore_log_init(void);
|
||||
void kore_log_file(const char *);
|
||||
|
||||
#if defined(KORE_USE_PYTHON)
|
||||
int kore_configure_setting(const char *, char *);
|
||||
|
@ -81,6 +81,7 @@ static int configure_bind_unix(char *);
|
||||
static int configure_attach(char *);
|
||||
static int configure_domain(char *);
|
||||
static int configure_privsep(char *);
|
||||
static int configure_logfile(char *);
|
||||
static int configure_workers(char *);
|
||||
static int configure_pidfile(char *);
|
||||
static int configure_rlimit_nofiles(char *);
|
||||
@ -212,6 +213,7 @@ static struct {
|
||||
const char *name;
|
||||
int (*configure)(char *);
|
||||
} config_settings[] = {
|
||||
{ "logfile", configure_logfile },
|
||||
{ "workers", configure_workers },
|
||||
{ "worker_max_connections", configure_max_connections },
|
||||
{ "worker_rlimit_nofiles", configure_rlimit_nofiles },
|
||||
@ -1771,6 +1773,13 @@ configure_websocket_timeout(char *option)
|
||||
|
||||
#endif /* !KORE_NO_HTTP */
|
||||
|
||||
static int
|
||||
configure_logfile(char *path)
|
||||
{
|
||||
kore_log_file(path);
|
||||
return (KORE_RESULT_OK);
|
||||
}
|
||||
|
||||
static int
|
||||
configure_workers(char *option)
|
||||
{
|
||||
|
17
src/log.c
17
src/log.c
@ -30,6 +30,8 @@ struct kore_wlog {
|
||||
static void log_print(int, const char *, ...);
|
||||
static void log_from_worker(struct kore_msg *, const void *);
|
||||
|
||||
static FILE *fp = NULL;
|
||||
|
||||
void
|
||||
kore_log_init(void)
|
||||
{
|
||||
@ -40,12 +42,23 @@ kore_log_init(void)
|
||||
const char *name = "kore";
|
||||
#endif
|
||||
|
||||
fp = stdout;
|
||||
|
||||
if (!kore_foreground)
|
||||
openlog(name, LOG_NDELAY | LOG_PID, LOG_DAEMON);
|
||||
|
||||
kore_msg_register(KORE_MSG_WORKER_LOG, log_from_worker);
|
||||
}
|
||||
|
||||
void
|
||||
kore_log_file(const char *path)
|
||||
{
|
||||
if ((fp = fopen(path, "a")) == NULL) {
|
||||
fp = stdout;
|
||||
fatal("fopen(%s): %s", path, errno_s);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
kore_log(int prio, const char *fmt, ...)
|
||||
{
|
||||
@ -129,8 +142,8 @@ log_print(int prio, const char *fmt, ...)
|
||||
break;
|
||||
}
|
||||
|
||||
vprintf(fmt, args);
|
||||
fflush(stdout);
|
||||
vfprintf(fp, fmt, args);
|
||||
fflush(fp);
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user