mirror of
https://github.com/osmarks/ngircd.git
synced 2025-06-26 07:03:00 +00:00
Split NoSyslog from behaviour of NoDaemon
Allows syslog to be enabled/disabled seperately from daemonization
This commit is contained in:
parent
79ffa9132b
commit
2debc2e833
@ -39,13 +39,13 @@
|
|||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
static bool Is_Daemon;
|
static bool Use_Syslog;
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Log_Message(int Level, const char *msg)
|
Log_Message(int Level, const char *msg)
|
||||||
{
|
{
|
||||||
if (!Is_Daemon) {
|
if (!Use_Syslog) {
|
||||||
/* log to console */
|
/* log to console */
|
||||||
fprintf(stdout, "[%ld:%d %4ld] %s\n", (long)getpid(), Level,
|
fprintf(stdout, "[%ld:%d %4ld] %s\n", (long)getpid(), Level,
|
||||||
(long)(time(NULL) - NGIRCd_Start), msg);
|
(long)(time(NULL) - NGIRCd_Start), msg);
|
||||||
@ -63,12 +63,12 @@ Log_Message(int Level, const char *msg)
|
|||||||
* Initialitze logging.
|
* Initialitze logging.
|
||||||
* This function is called before the configuration file is read in.
|
* This function is called before the configuration file is read in.
|
||||||
*
|
*
|
||||||
* @param Daemon_Mode Set to true if ngIRCd is running as daemon.
|
* @param Syslog_Mode Set to true if ngIRCd is running as daemon.
|
||||||
*/
|
*/
|
||||||
GLOBAL void
|
GLOBAL void
|
||||||
Log_Init(bool Daemon_Mode)
|
Log_Init(bool Syslog_Mode)
|
||||||
{
|
{
|
||||||
Is_Daemon = Daemon_Mode;
|
Use_Syslog = Syslog_Mode;
|
||||||
|
|
||||||
#ifdef SYSLOG
|
#ifdef SYSLOG
|
||||||
#ifndef LOG_CONS /* Kludge: mips-dec-ultrix4.5 has no LOG_CONS */
|
#ifndef LOG_CONS /* Kludge: mips-dec-ultrix4.5 has no LOG_CONS */
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#define LOG_snotice 1024
|
#define LOG_snotice 1024
|
||||||
|
|
||||||
GLOBAL void Log_Init PARAMS(( bool Daemon_Mode ));
|
GLOBAL void Log_Init PARAMS(( bool Syslog_Mode ));
|
||||||
GLOBAL void Log_Exit PARAMS(( void ));
|
GLOBAL void Log_Exit PARAMS(( void ));
|
||||||
|
|
||||||
GLOBAL void Log PARAMS(( int Level, const char *Format, ... ));
|
GLOBAL void Log PARAMS(( int Level, const char *Format, ... ));
|
||||||
|
@ -74,7 +74,7 @@ GLOBAL int
|
|||||||
main(int argc, const char *argv[])
|
main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
bool ok, configtest = false;
|
bool ok, configtest = false;
|
||||||
bool NGIRCd_NoDaemon = false;
|
bool NGIRCd_NoDaemon = false, NGIRCd_NoSyslog = false;
|
||||||
int i;
|
int i;
|
||||||
size_t n;
|
size_t n;
|
||||||
|
|
||||||
@ -130,6 +130,7 @@ main(int argc, const char *argv[])
|
|||||||
}
|
}
|
||||||
if (strcmp(argv[i], "--nodaemon") == 0) {
|
if (strcmp(argv[i], "--nodaemon") == 0) {
|
||||||
NGIRCd_NoDaemon = true;
|
NGIRCd_NoDaemon = true;
|
||||||
|
NGIRCd_NoSyslog = true;
|
||||||
ok = true;
|
ok = true;
|
||||||
}
|
}
|
||||||
if (strcmp(argv[i], "--passive") == 0) {
|
if (strcmp(argv[i], "--passive") == 0) {
|
||||||
@ -178,6 +179,7 @@ main(int argc, const char *argv[])
|
|||||||
|
|
||||||
if (argv[i][n] == 'n') {
|
if (argv[i][n] == 'n') {
|
||||||
NGIRCd_NoDaemon = true;
|
NGIRCd_NoDaemon = true;
|
||||||
|
NGIRCd_NoSyslog = true;
|
||||||
ok = true;
|
ok = true;
|
||||||
}
|
}
|
||||||
if (argv[i][n] == 'p') {
|
if (argv[i][n] == 'p') {
|
||||||
@ -249,7 +251,7 @@ main(int argc, const char *argv[])
|
|||||||
NGIRCd_SignalRestart = false;
|
NGIRCd_SignalRestart = false;
|
||||||
NGIRCd_SignalQuit = false;
|
NGIRCd_SignalQuit = false;
|
||||||
|
|
||||||
Log_Init(!NGIRCd_NoDaemon);
|
Log_Init(!NGIRCd_NoSyslog);
|
||||||
Random_Init();
|
Random_Init();
|
||||||
Conf_Init();
|
Conf_Init();
|
||||||
Log_ReInit();
|
Log_ReInit();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user