1
0
mirror of https://github.com/osmarks/ngircd.git synced 2024-12-12 01:40:27 +00:00

Convert uses of Log(LOG_DEBUG, ...) to LogDebug()

This commit is contained in:
Jules Maselbas 2022-04-26 15:41:28 +02:00 committed by Alexander Barton
parent b0caf5984e
commit 93e36555e3
14 changed files with 39 additions and 58 deletions

View File

@ -68,7 +68,7 @@ array_alloc(array * a, size_t size, size_t pos)
if (a->allocated < alloc) { if (a->allocated < alloc) {
#if DEBUG_ARRAY #if DEBUG_ARRAY
Log(LOG_DEBUG, "array_alloc(): changing size from %u to %u bytes.", LogDebug("array_alloc(): changing size from %u to %u bytes.",
a->allocated, alloc); a->allocated, alloc);
#endif #endif
tmp = realloc(a->mem, alloc); tmp = realloc(a->mem, alloc);
@ -169,7 +169,7 @@ array_catb(array * dest, const char *src, size_t len)
assert(ptr != NULL); assert(ptr != NULL);
#if DEBUG_ARRAY #if DEBUG_ARRAY
Log(LOG_DEBUG, LogDebug(
"array_catb(): appending %u bytes to array (now %u bytes in array).", "array_catb(): appending %u bytes to array (now %u bytes in array).",
len, tmp); len, tmp);
#endif #endif
@ -249,7 +249,7 @@ array_free(array * a)
{ {
assert(a != NULL); assert(a != NULL);
#if DEBUG_ARRAY #if DEBUG_ARRAY
Log(LOG_DEBUG, LogDebug(
"array_free(): %u bytes free'd (%u bytes still used at time of free()).", "array_free(): %u bytes free'd (%u bytes still used at time of free()).",
a->allocated, a->used); a->allocated, a->used);
#endif #endif
@ -315,7 +315,7 @@ array_moveleft(array * a, size_t membersize, size_t pos)
return; /* nothing to do */ return; /* nothing to do */
#if DEBUG_ARRAY #if DEBUG_ARRAY
Log(LOG_DEBUG, LogDebug(
"array_moveleft(): %u bytes used in array, starting at position %u.", "array_moveleft(): %u bytes used in array, starting at position %u.",
a->used, bytepos); a->used, bytepos);
#endif #endif

View File

@ -148,7 +148,7 @@ Channel_InitPredefined( void )
for (n = 0; n < conf_chan->modes_num; n++) { for (n = 0; n < conf_chan->modes_num; n++) {
Req.argc = 1; Req.argc = 1;
strlcpy(modes, conf_chan->modes[n], sizeof(modes)); strlcpy(modes, conf_chan->modes[n], sizeof(modes));
Log(LOG_DEBUG, "Evaluate \"MODE %s %s\".", name, modes); LogDebug("Evaluate \"MODE %s %s\".", name, modes);
c = strtok(modes, " "); c = strtok(modes, " ");
while (c && Req.argc < 15) { while (c && Req.argc < 15) {
Req.argv[Req.argc++] = c; Req.argv[Req.argc++] = c;

View File

@ -1499,9 +1499,7 @@ Client_RegisterWhowas( CLIENT *Client )
slot = Last_Whowas + 1; slot = Last_Whowas + 1;
if( slot >= MAX_WHOWAS || slot < 0 ) slot = 0; if( slot >= MAX_WHOWAS || slot < 0 ) slot = 0;
#ifdef DEBUG LogDebug( "Saving WHOWAS information to slot %d ...", slot );
Log( LOG_DEBUG, "Saving WHOWAS information to slot %d ...", slot );
#endif
My_Whowas[slot].time = now; My_Whowas[slot].time = now;
strlcpy( My_Whowas[slot].id, Client_ID( Client ), strlcpy( My_Whowas[slot].id, Client_ID( Client ),
@ -1703,10 +1701,10 @@ Client_DebugDump(void)
{ {
CLIENT *c; CLIENT *c;
Log(LOG_DEBUG, "Client status:"); LogDebug("Client status:");
c = My_Clients; c = My_Clients;
while (c) { while (c) {
Log(LOG_DEBUG, LogDebug(
" - %s: type=%d, host=%s, user=%s, conn=%d, start=%ld, flags=%s", " - %s: type=%d, host=%s, user=%s, conn=%d, start=%ld, flags=%s",
Client_ID(c), Client_Type(c), Client_Hostname(c), Client_ID(c), Client_Type(c), Client_Hostname(c),
Client_User(c), Client_Conn(c), Client_StartTime(c), Client_User(c), Client_Conn(c), Client_StartTime(c),

View File

@ -942,16 +942,13 @@ Read_Config(bool TestOnly, bool IsStarting)
if( Conf_Server[i].conn_id == Conf_Server[n].conn_id ) { if( Conf_Server[i].conn_id == Conf_Server[n].conn_id ) {
Init_Server_Struct( &Conf_Server[n] ); Init_Server_Struct( &Conf_Server[n] );
#ifdef DEBUG LogDebug("Deleted unused duplicate server %d (kept %d).", n, i);
Log(LOG_DEBUG,"Deleted unused duplicate server %d (kept %d).",
n, i );
#endif
} }
} }
} else { } else {
/* Mark server as "once" */ /* Mark server as "once" */
Conf_Server[i].flags |= CONF_SFLAG_ONCE; Conf_Server[i].flags |= CONF_SFLAG_ONCE;
Log( LOG_DEBUG, "Marked server %d as \"once\"", i ); LogDebug("Marked server %d as \"once\"", i);
} }
} }
} }
@ -2134,8 +2131,7 @@ Validate_Config(bool Configtest, bool Rehash)
servers_once++; servers_once++;
} }
} }
Log(LOG_DEBUG, LogDebug("Configuration: Operators=%ld, Servers=%d[%d], Channels=%ld",
"Configuration: Operators=%ld, Servers=%d[%d], Channels=%ld",
array_length(&Conf_Opers, sizeof(struct Conf_Oper)), array_length(&Conf_Opers, sizeof(struct Conf_Oper)),
servers, servers_once, servers, servers_once,
array_length(&Conf_Channels, sizeof(struct Conf_Channel))); array_length(&Conf_Channels, sizeof(struct Conf_Channel)));
@ -2236,11 +2232,11 @@ Conf_DebugDump(void)
{ {
int i; int i;
Log(LOG_DEBUG, "Configured servers:"); LogDebug("Configured servers:");
for (i = 0; i < MAX_SERVERS; i++) { for (i = 0; i < MAX_SERVERS; i++) {
if (! Conf_Server[i].name[0]) if (! Conf_Server[i].name[0])
continue; continue;
Log(LOG_DEBUG, LogDebug(
" - %s: %s:%d, last=%ld, group=%d, flags=%d, conn=%d", " - %s: %s:%d, last=%ld, group=%d, flags=%d, conn=%d",
Conf_Server[i].name, Conf_Server[i].host, Conf_Server[i].name, Conf_Server[i].host,
Conf_Server[i].port, Conf_Server[i].lasttry, Conf_Server[i].port, Conf_Server[i].lasttry,

View File

@ -21,11 +21,8 @@
#include <assert.h> #include <assert.h>
#include <time.h> #include <time.h>
#ifdef DEBUG #include "log.h"
# include "log.h"
#endif
#include "conn.h" #include "conn.h"
#include "conf.h" #include "conf.h"
#include "conn-func.h" #include "conn-func.h"
@ -116,13 +113,10 @@ Conn_SetPenalty(CONN_ID Idx, time_t Seconds)
My_Connections[Idx].delaytime += Seconds; My_Connections[Idx].delaytime += Seconds;
#ifdef DEBUG LogDebug("Add penalty time on connection %d: %ld second%s, total %ld second%s.",
Log(LOG_DEBUG,
"Add penalty time on connection %d: %ld second%s, total %ld second%s.",
Idx, (long)Seconds, Seconds != 1 ? "s" : "", Idx, (long)Seconds, Seconds != 1 ? "s" : "",
My_Connections[Idx].delaytime - t, My_Connections[Idx].delaytime - t,
My_Connections[Idx].delaytime - t != 1 ? "s" : ""); My_Connections[Idx].delaytime - t != 1 ? "s" : "");
#endif
} /* Conn_SetPenalty */ } /* Conn_SetPenalty */
GLOBAL void GLOBAL void

View File

@ -142,7 +142,7 @@ Zip_Flush( CONN_ID Idx )
out->avail_out = (uInt)sizeof zipbuf; out->avail_out = (uInt)sizeof zipbuf;
#if DEBUG_ZIP #if DEBUG_ZIP
Log(LOG_DEBUG, "out->avail_in %d, out->avail_out %d", LogDebug("out->avail_in %d, out->avail_out %d",
out->avail_in, out->avail_out); out->avail_in, out->avail_out);
#endif #endif
result = deflate( out, Z_SYNC_FLUSH ); result = deflate( out, Z_SYNC_FLUSH );
@ -165,7 +165,7 @@ Zip_Flush( CONN_ID Idx )
zipbuf_used = WRITEBUFFER_SLINK_LEN - out->avail_out; zipbuf_used = WRITEBUFFER_SLINK_LEN - out->avail_out;
#if DEBUG_ZIP #if DEBUG_ZIP
Log(LOG_DEBUG, "zipbuf_used: %d", zipbuf_used); LogDebug("zipbuf_used: %d", zipbuf_used);
#endif #endif
if (!array_catb(&My_Connections[Idx].wbuf, if (!array_catb(&My_Connections[Idx].wbuf,
(char *)zipbuf, (size_t) zipbuf_used)) { (char *)zipbuf, (size_t) zipbuf_used)) {
@ -217,7 +217,7 @@ Unzip_Buffer( CONN_ID Idx )
in->avail_out = (uInt)sizeof unzipbuf; in->avail_out = (uInt)sizeof unzipbuf;
#if DEBUG_ZIP #if DEBUG_ZIP
Log(LOG_DEBUG, "in->avail_in %d, in->avail_out %d", LogDebug("in->avail_in %d, in->avail_out %d",
in->avail_in, in->avail_out); in->avail_in, in->avail_out);
#endif #endif
result = inflate( in, Z_SYNC_FLUSH ); result = inflate( in, Z_SYNC_FLUSH );
@ -232,7 +232,7 @@ Unzip_Buffer( CONN_ID Idx )
in_len = z_rdatalen - in->avail_in; in_len = z_rdatalen - in->avail_in;
unzipbuf_used = READBUFFER_LEN - in->avail_out; unzipbuf_used = READBUFFER_LEN - in->avail_out;
#if DEBUG_ZIP #if DEBUG_ZIP
Log(LOG_DEBUG, "unzipbuf_used: %d - %d = %d", READBUFFER_LEN, LogDebug("unzipbuf_used: %d - %d = %d", READBUFFER_LEN,
in->avail_out, unzipbuf_used); in->avail_out, unzipbuf_used);
#endif #endif
assert(unzipbuf_used <= READBUFFER_LEN); assert(unzipbuf_used <= READBUFFER_LEN);

View File

@ -875,7 +875,7 @@ va_dcl
#ifdef SNIFFER #ifdef SNIFFER
if (NGIRCd_Sniffer) if (NGIRCd_Sniffer)
Log(LOG_DEBUG, " -> connection %d: '%s'.", Idx, buffer); LogDebug("-> connection %d: '%s'.", Idx, buffer);
#endif #endif
len = strlcat( buffer, "\r\n", sizeof( buffer )); len = strlcat( buffer, "\r\n", sizeof( buffer ));
@ -2698,11 +2698,11 @@ Conn_DebugDump(void)
{ {
int i; int i;
Log(LOG_DEBUG, "Connection status:"); LogDebug("Connection status:");
for (i = 0; i < Pool_Size; i++) { for (i = 0; i < Pool_Size; i++) {
if (My_Connections[i].sock == NONE) if (My_Connections[i].sock == NONE)
continue; continue;
Log(LOG_DEBUG, LogDebug(
" - %d: host=%s, lastdata=%ld, lastping=%ld, delaytime=%ld, flag=%d, options=%d, bps=%d, client=%s", " - %d: host=%s, lastdata=%ld, lastping=%ld, delaytime=%ld, flag=%d, options=%d, bps=%d, client=%s",
My_Connections[i].sock, My_Connections[i].host, My_Connections[i].sock, My_Connections[i].host,
My_Connections[i].lastdata, My_Connections[i].lastping, My_Connections[i].lastdata, My_Connections[i].lastping,

View File

@ -148,7 +148,7 @@ static void io_docallback PARAMS((int fd, short what));
static void static void
io_debug(const char *s, int fd, int what) io_debug(const char *s, int fd, int what)
{ {
Log(LOG_DEBUG, "%s: %d, %d\n", s, fd, what); LogDebug("%s: %d, %d\n", s, fd, what);
} }
#else #else
static inline void static inline void

View File

@ -774,7 +774,7 @@ IRC_PING(CLIENT *Client, REQUEST *Req)
return IRC_WriteErrClient(Client, ERR_NOSUCHSERVER_MSG, return IRC_WriteErrClient(Client, ERR_NOSUCHSERVER_MSG,
Client_ID(Client), Req->prefix); Client_ID(Client), Req->prefix);
Log(LOG_DEBUG, "Connection %d: got PING, sending PONG ...", LogDebug("Connection %d: got PING, sending PONG ...",
Client_Conn(Client)); Client_Conn(Client));
#ifdef STRICT_RFC #ifdef STRICT_RFC
@ -877,9 +877,7 @@ IRC_PONG(CLIENT *Client, REQUEST *Req)
(long)(time(NULL) - Conn_GetSignon(conn)), (long)(time(NULL) - Conn_GetSignon(conn)),
time(NULL) - Conn_GetSignon(conn) == 1 ? "" : "s", time(NULL) - Conn_GetSignon(conn) == 1 ? "" : "s",
Client_UserCount(), Channel_CountVisible(NULL)); Client_UserCount(), Channel_CountVisible(NULL));
} } else {
#ifdef DEBUG
else {
if (Conn_LastPing(conn) > 1) if (Conn_LastPing(conn) > 1)
LogDebug("Connection %d: received PONG. Lag: %ld seconds.", LogDebug("Connection %d: received PONG. Lag: %ld seconds.",
conn, (long)(time(NULL) - Conn_LastPing(conn))); conn, (long)(time(NULL) - Conn_LastPing(conn)));
@ -887,7 +885,6 @@ IRC_PONG(CLIENT *Client, REQUEST *Req)
LogDebug("Got unexpected PONG on connection %d. Ignored.", LogDebug("Got unexpected PONG on connection %d. Ignored.",
conn); conn);
} }
#endif
/* We got a PONG, so signal that none is pending on this connection. */ /* We got a PONG, so signal that none is pending on this connection. */
Conn_UpdatePing(conn, 1); Conn_UpdatePing(conn, 1);

View File

@ -281,7 +281,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
break; break;
default: default:
if (Client_Type(Client) != CLIENT_SERVER) { if (Client_Type(Client) != CLIENT_SERVER) {
Log(LOG_DEBUG, LogDebug(
"Unknown mode \"%c%c\" from \"%s\"!?", "Unknown mode \"%c%c\" from \"%s\"!?",
set ? '+' : '-', *mode_ptr, set ? '+' : '-', *mode_ptr,
Client_ID(Origin)); Client_ID(Origin));
@ -292,7 +292,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
*mode_ptr); *mode_ptr);
x[0] = '\0'; x[0] = '\0';
} else { } else {
Log(LOG_DEBUG, LogDebug(
"Handling unknown mode \"%c%c\" from \"%s\" for \"%s\" ...", "Handling unknown mode \"%c%c\" from \"%s\" for \"%s\" ...",
set ? '+' : '-', *mode_ptr, set ? '+' : '-', *mode_ptr,
Client_ID(Origin), Client_ID(Target)); Client_ID(Origin), Client_ID(Target));
@ -823,7 +823,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
break; break;
default: default:
if (Client_Type(Client) != CLIENT_SERVER) { if (Client_Type(Client) != CLIENT_SERVER) {
Log(LOG_DEBUG, LogDebug(
"Unknown mode \"%c%c\" from \"%s\" on %s!?", "Unknown mode \"%c%c\" from \"%s\" on %s!?",
set ? '+' : '-', *mode_ptr, set ? '+' : '-', *mode_ptr,
Client_ID(Origin), Channel_Name(Channel)); Client_ID(Origin), Channel_Name(Channel));
@ -833,7 +833,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
Channel_Name(Channel)); Channel_Name(Channel));
x[0] = '\0'; x[0] = '\0';
} else { } else {
Log(LOG_DEBUG, LogDebug(
"Handling unknown mode \"%c%c\" from \"%s\" on %s ...", "Handling unknown mode \"%c%c\" from \"%s\" on %s ...",
set ? '+' : '-', *mode_ptr, set ? '+' : '-', *mode_ptr,
Client_ID(Origin), Channel_Name(Channel)); Client_ID(Origin), Channel_Name(Channel));

View File

@ -298,7 +298,7 @@ IRC_NJOIN( CLIENT *Client, REQUEST *Req )
"Failed to join client \"%s\" to channel \"%s\" (NJOIN): killing it!", "Failed to join client \"%s\" to channel \"%s\" (NJOIN): killing it!",
ptr, channame); ptr, channame);
IRC_KillClient(NULL, NULL, ptr, "Internal NJOIN error!"); IRC_KillClient(NULL, NULL, ptr, "Internal NJOIN error!");
Log(LOG_DEBUG, "... done."); LogDebug("... done.");
goto skip_njoin; goto skip_njoin;
} }

View File

@ -490,9 +490,7 @@ Pidfile_Delete( void )
/* Pidfile configured? */ /* Pidfile configured? */
if( ! Conf_PidFile[0] ) return; if( ! Conf_PidFile[0] ) return;
#ifdef DEBUG LogDebug( "Removing PID file (%s) ...", Conf_PidFile );
Log( LOG_DEBUG, "Removing PID file (%s) ...", Conf_PidFile );
#endif
if( unlink( Conf_PidFile )) if( unlink( Conf_PidFile ))
Log( LOG_ERR, "Error unlinking PID file (%s): %s", Conf_PidFile, strerror( errno )); Log( LOG_ERR, "Error unlinking PID file (%s): %s", Conf_PidFile, strerror( errno ));
@ -514,9 +512,7 @@ Pidfile_Create(pid_t pid)
/* Pidfile configured? */ /* Pidfile configured? */
if( ! Conf_PidFile[0] ) return; if( ! Conf_PidFile[0] ) return;
#ifdef DEBUG LogDebug( "Creating PID file (%s) ...", Conf_PidFile );
Log( LOG_DEBUG, "Creating PID file (%s) ...", Conf_PidFile );
#endif
pidfd = open( Conf_PidFile, O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); pidfd = open( Conf_PidFile, O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
if ( pidfd < 0 ) { if ( pidfd < 0 ) {
@ -817,7 +813,7 @@ NGIRCd_Init(bool NGIRCd_NoDaemon)
if (pwd) { if (pwd) {
if (chdir(pwd->pw_dir) == 0) if (chdir(pwd->pw_dir) == 0)
Log(LOG_DEBUG, LogDebug(
"Changed working directory to \"%s\" ...", "Changed working directory to \"%s\" ...",
pwd->pw_dir); pwd->pw_dir);
else else

View File

@ -183,7 +183,7 @@ Parse_Request( CONN_ID Idx, char *Request )
assert( Request != NULL ); assert( Request != NULL );
#ifdef SNIFFER #ifdef SNIFFER
if( NGIRCd_Sniffer ) Log( LOG_DEBUG, " <- connection %d: '%s'.", Idx, Request ); if( NGIRCd_Sniffer ) LogDebug( " <- connection %d: '%s'.", Idx, Request );
#endif #endif
Init_Request( &req ); Init_Request( &req );

View File

@ -46,17 +46,17 @@ static const int signals_catch[] = {
static void static void
Dump_State(void) Dump_State(void)
{ {
Log(LOG_DEBUG, "--- Internal server state: %s ---", LogDebug("--- Internal server state: %s ---",
Client_ID(Client_ThisServer())); Client_ID(Client_ThisServer()));
#ifdef HAVE_LONG_LONG #ifdef HAVE_LONG_LONG
Log(LOG_DEBUG, "time()=%llu", (unsigned long long)time(NULL)); LogDebug("time()=%llu", (unsigned long long)time(NULL));
#else #else
Log(LOG_DEBUG, "time()=%lu", (unsigned long)time(NULL)); LogDebug("time()=%lu", (unsigned long)time(NULL));
#endif #endif
Conf_DebugDump(); Conf_DebugDump();
Conn_DebugDump(); Conn_DebugDump();
Client_DebugDump(); Client_DebugDump();
Log(LOG_DEBUG, "--- End of state dump ---"); LogDebug("--- End of state dump ---");
} /* Dump_State */ } /* Dump_State */
#endif #endif
@ -235,7 +235,7 @@ Signal_Handler_BH(int Signal)
} }
break; break;
default: default:
Log(LOG_DEBUG, "Got signal %d! Ignored.", Signal); LogDebug("Got signal %d! Ignored.", Signal);
#endif #endif
} }
Signal_Unblock(Signal); Signal_Unblock(Signal);