mirror of
https://github.com/osmarks/ngircd.git
synced 2024-12-12 01:40:27 +00:00
Merge branch 'katp32/master'
Thanks Katherine Peeters for the patch and pull request! Closes #294. * katp32/master: Improve documentation for --syslog Added command line flag to enable syslog Split NoSyslog from behaviour of NoDaemon
This commit is contained in:
commit
8fdb8f90b1
@ -53,6 +53,9 @@ Don't fork a child and don't detach from controlling terminal.
|
|||||||
All log messages go to the console and you can use CTRL-C to
|
All log messages go to the console and you can use CTRL-C to
|
||||||
terminate the server.
|
terminate the server.
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-y\fR, \fB\-\-syslog\fR
|
||||||
|
Write log messages to the syslog even when running in the foreground.
|
||||||
|
.TP
|
||||||
\fB\-p\fR, \fB\-\-passive\fR
|
\fB\-p\fR, \fB\-\-passive\fR
|
||||||
Disable automatic connections to other servers. You can use the IRC command
|
Disable automatic connections to other servers. You can use the IRC command
|
||||||
CONNECT later on as IRC Operator to link this ngIRCd to other servers.
|
CONNECT later on as IRC Operator to link this ngIRCd to other servers.
|
||||||
|
@ -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 configured to log to the syslog.
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
|
|
||||||
@ -126,6 +126,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) {
|
||||||
@ -137,6 +138,12 @@ main(int argc, const char *argv[])
|
|||||||
NGIRCd_Sniffer = true;
|
NGIRCd_Sniffer = true;
|
||||||
ok = true;
|
ok = true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef SYSLOG
|
||||||
|
if (strcmp(argv[i], "--syslog") == 0) {
|
||||||
|
NGIRCd_NoSyslog = false;
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (strcmp(argv[i], "--version") == 0) {
|
if (strcmp(argv[i], "--version") == 0) {
|
||||||
Show_Version();
|
Show_Version();
|
||||||
@ -172,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') {
|
||||||
@ -193,6 +201,12 @@ main(int argc, const char *argv[])
|
|||||||
Show_Version();
|
Show_Version();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
#ifdef SYSLOG
|
||||||
|
if (argv[i][n] == 'y') {
|
||||||
|
NGIRCd_NoSyslog = false;
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@ -241,7 +255,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();
|
||||||
@ -467,6 +481,9 @@ Show_Help( void )
|
|||||||
#endif
|
#endif
|
||||||
puts( " -t, --configtest read, validate and display configuration; then exit" );
|
puts( " -t, --configtest read, validate and display configuration; then exit" );
|
||||||
puts( " -V, --version output version information and exit" );
|
puts( " -V, --version output version information and exit" );
|
||||||
|
#ifdef SYSLOG
|
||||||
|
puts( " -y, --syslog log to syslog even when running in the foreground (-n)" );
|
||||||
|
#endif
|
||||||
puts( " -h, --help display this help and exit" );
|
puts( " -h, --help display this help and exit" );
|
||||||
} /* Show_Help */
|
} /* Show_Help */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user