// SPDX-License-Identifier: GPL-3.0-or-later
#include <daemon/main.h>
#include "../libnetdata.h"
#ifdef HAVE_BACKTRACE
#include <execinfo.h>
#endif
int web_server_is_multithreaded = 1;
const char *program_name = "";
uint64_t debug_flags = 0;
int access_log_syslog = 1;
int error_log_syslog = 1;
int collector_log_syslog = 1;
int output_log_syslog = 1; // debug log
int health_log_syslog = 1;
int stdaccess_fd = -1;
FILE *stdaccess = NULL;
int stdhealth_fd = -1;
FILE *stdhealth = NULL;
int stdcollector_fd = -1;
FILE *stderror = NULL;
const char *stdaccess_filename = NULL;
const char *stderr_filename = NULL;
const char *stdout_filename = NULL;
const char *facility_log = NULL;
const char *stdhealth_filename = NULL;
const char *stdcollector_filename = NULL;
#ifdef ENABLE_ACLK
const char *aclklog_filename = NULL;
int aclklog_fd = -1;
FILE *aclklog = NULL;
int aclklog_syslog = 1;
int aclklog_enabled = 0;
#endif
// ----------------------------------------------------------------------------
// Log facility(https://tools.ietf.org/html/rfc5424)
//
// The facilities accepted in the Netdata are in according with the following
// header files for their respective operating system:
// sys/syslog.h (Linux )
// sys/sys/syslog.h (FreeBSD)
// bsd/sys/syslog.h (darwin-xnu)
#define LOG_AUTH_KEY "auth"
#define LOG_AUTHPRIV_KEY "authpriv"
#ifdef __FreeBSD__
# define LOG_CONSOLE_KEY "console"
#endif
#define LOG_CRON_KEY "cron"
#define LOG_DAEMON_KEY "daemon"
#define LOG_FTP_KEY "ftp"
#ifdef __APPLE__
# define LOG_INSTALL_KEY "install"
#endif
#define LOG_KERN_KEY "kern"
#define LOG_LPR_KEY "lpr"
#define LOG_MAIL_KEY "mail"
//#define LOG_INTERNAL_MARK_KEY "mark"
#ifdef __APPLE__
# define LOG_NETINFO_KEY "netinfo"
# define LOG_RAS_KEY "ras"
# define LOG_REMOTEAUTH_KEY "remoteauth"
#endif
#define LOG_NEWS_KEY "news"
#ifdef __FreeBSD__
# define LOG_NTP_KEY "ntp"
#endif
#define LOG_SECURITY_KEY "security"
#define LOG_SYSLOG_KEY "syslog"
#define LOG_USER_KEY "user"
#define LOG_UUCP_KEY "uucp"
#ifdef __APPLE__
# define LOG_LAUNCHD_KEY "launchd"
#endif
#define LOG_LOCAL0_KEY "local0"
#define LOG_LOCAL1_KEY "local1"
#define LOG_LOCAL2_KEY "local2"
#define LOG_LOCAL3_KEY "local3"
#define LOG_LOCAL4_KEY "local4"
#define LOG_LOCAL5_KEY "local5"
#define LOG_LOCAL6_KEY "local6"
#define LOG_LOCAL7_KEY "local7"
static int log_facility_id(const char *facility_name)
{
static int
hash_auth = 0,
hash_authpriv = 0,
#ifdef __FreeBSD__
hash_console = 0,
#endif
hash_cron = 0,
hash_daemon = 0,
hash_ftp = 0,
#ifdef __APPLE__
hash_install = 0,
#endif
hash_kern = 0,
hash_lpr = 0,
hash_mail = 0,
// hash_mark = 0,
#ifdef __APPLE__
hash_netinfo = 0,
hash_ras = 0,
hash_remoteauth = 0,
#endif
hash_news = 0,
#ifdef __FreeBSD__
hash_ntp = 0,
#endif
hash_security = 0,
hash_syslog = 0,
hash_user = 0,
hash_uucp = 0,
#ifdef __APPLE__
hash_launchd = 0,
#endif
hash_local0 = 0,
hash_local1 = 0,
hash_local2 = 0,
hash_local3 = 0,
hash_local4 = 0,
hash_local5 = 0,
hash_local6 =