Skip to content

Commit

Permalink
rip out log interval, switch logfile to line buffered, yeah, its posi…
Browse files Browse the repository at this point in the history
…x 2001
  • Loading branch information
Michael Ortmann committed Oct 13, 2023
1 parent 5e12bb9 commit aad25fb
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 61 deletions.
2 changes: 1 addition & 1 deletion doc/sphinx_source/tutorials/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ Now that your Eggdrop is on IRC and you've introduced yourself as owner, it's ti
No show?
~~~~~~~~

If your bot didn't appear on IRC, you should log in to the shell and view the bot's logfile (the default in the config file is "logs/eggdrop.log"). Note that logfile entries are not written to disk immediately unless quick-logs is enabled, so you may have to wait a few minutes before the logfile appears, or contains messages that indicate why your bot isn't showing up.
If your bot didn't appear on IRC, you should log in to the shell and view the bot's logfile (the default in the config file is "logs/eggdrop.log").

Additionally, you can kill the bot via the command line (``kill pid``, the pid is shown to you when you started the bot or can be viewed by running ``ps x``) and then restart it with the -mnt flag, which will launch you directly into the partyline, to assist with troubleshooting. Note that if you use the -nt flag, the bot will not persist and you will kill it once you quit the partyline.

Expand Down
7 changes: 0 additions & 7 deletions doc/sphinx_source/using/core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,6 @@ the logfile of the next day.
reaches the size of 550 kilobytes. Note that this only works if you
have keep-all-logs set to 0 (OFF).

set quick-logs 0
This could be good if you have had a problem with logfiles filling
your quota/hard disk or if you log +p and publish it to the web, and
you need more up-to-date info. Note that this setting might increase
the CPU usage of your bot (on the other hand it will decrease your RAM
usage).

set raw-log 0
This setting allows you the logging of raw incoming server traffic via
console/log flag 'r', raw outgoing server traffic via console/log mode
Expand Down
3 changes: 0 additions & 3 deletions eggdrop.conf
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@ set max-logs 20
# have keep-all-logs 0 (OFF).
set max-logsize 0

# Interval between logfile saving operations in seconds.
set log-interval 15

# This setting allows you the logging of raw incoming server traffic via
# console/log flag 'r', raw outgoing server traffic via console/log mode 'v',
# raw incoming botnet traffic via console/log mode 't', raw outgoing botnet
Expand Down
16 changes: 3 additions & 13 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@
#endif

extern char origbotname[], botnetnick[];
extern int dcc_total, conmask, cache_hit, cache_miss, max_logs, log_interval,
quiet_save;
extern int dcc_total, conmask, cache_hit, cache_miss, max_logs, quiet_save;
extern struct dcc_t *dcc;
extern struct userrec *userlist;
extern struct chanset_t *chanset;
Expand Down Expand Up @@ -141,7 +140,6 @@ char ver[41]; /* Version info (short form) */
volatile sig_atomic_t do_restart = 0; /* .restart has been called, restart ASAP */
int resolve_timeout = RES_TIMEOUT; /* Hostname/address lookup timeout */
char quit_msg[1024]; /* Quit message */
int log_elapsed = 1;

/* Moved here for n flag warning, put back in do_arg if removed */
unsigned char cliflags = 0;
Expand Down Expand Up @@ -188,7 +186,6 @@ void fatal(const char *s, int recoverable)
int i;

putlog(LOG_MISC, "*", "* %s", s);
flushlogs();
for (i = 0; i < dcc_total; i++)
if (dcc[i].sock >= 0)
killsock(dcc[i].sock);
Expand Down Expand Up @@ -638,18 +635,10 @@ static void core_secondly()
tell_mem_status_dcc(DP_STDOUT);
}
}
if (log_elapsed < log_interval)
log_elapsed++;
else {
flushlogs();
check_logsize();
log_elapsed = 1;
}
nowmins = time(NULL) / 60;
if (nowmins > lastmin) {
memcpy(&nowtm, localtime(&now), sizeof(struct tm));
i = 0;

/* Once a minute */
++lastmin;
call_hook(HOOK_MINUTELY);
Expand All @@ -670,6 +659,7 @@ static void core_secondly()
if (((int) (nowtm.tm_min / 5) * 5) == (nowtm.tm_min)) { /* 5 min */
call_hook(HOOK_5MINUTELY);
check_botnet_pings();

if (!miltime) { /* At midnight */
char s[25];
int j;
Expand Down Expand Up @@ -717,6 +707,7 @@ static void core_minutely()
{
check_tcl_time_and_cron(&nowtm);
do_check_timers(&timer);
check_logsize();
}

static void core_hourly()
Expand Down Expand Up @@ -953,7 +944,6 @@ static void mainloop(int toplevel)
putlog(LOG_MISC, "*", "%s", MOD_STAGNANT);
}

flushlogs();
kill_tcl();
init_tcl(argc, argv);
init_language(0);
Expand Down
36 changes: 2 additions & 34 deletions src/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,10 @@ void putlog (int type, char *chname, const char *format, ...)
if (keep_all_logs) {
snprintf(path, sizeof path, "%s%s", logs[i].filename, ct);
logs[i].f = fopen(path, "a");
setvbuf(logs[i].f, NULL, _IOLBF, 0); /* line buffered */
} else
logs[i].f = fopen(logs[i].filename, "a");
setvbuf(logs[i].f, NULL, _IOLBF, 0); /* line buffered */
}
if (logs[i].f != NULL) {
/* Check if this is the same as the last line added to
Expand Down Expand Up @@ -651,7 +653,6 @@ void logsuffix_change(char *s)
}
for (i = 0; i < max_logs; i++) {
if (logs[i].f) {
fflush(logs[i].f);
fclose(logs[i].f);
logs[i].f = NULL;
}
Expand All @@ -676,7 +677,6 @@ void check_logsize()
if (logs[i].f) {
/* write to the log before closing it huh.. */
putlog(LOG_MISC, "*", MISC_CLOGS, logs[i].filename, ss.st_size);
fflush(logs[i].f);
fclose(logs[i].f);
logs[i].f = NULL;
}
Expand All @@ -691,38 +691,6 @@ void check_logsize()
}
}

/* Flush the logfiles to disk
*/
void flushlogs()
{
int i;

/* Logs may not be initialised yet. */
if (!logs)
return;

/* Now also checks to see if there's a repeat message and
* displays the 'last message repeated...' stuff too <cybah>
*/
for (i = 0; i < max_logs; i++) {
if (logs[i].f != NULL) {
if (logs[i].repeats > 0) {
/* Repeat.. display 'last message repeated x times' and reset repeats.
*/
char stamp[33];

strftime(stamp, sizeof(stamp) - 1, log_ts, localtime(&now));
fprintf(logs[i].f, "%s ", stamp);
fprintf(logs[i].f, MISC_LOGREPEAT, logs[i].repeats);
/* Reset repeats */
logs[i].repeats = 0;
}
fflush(logs[i].f);
}
}
}


/*
* String substitution functions
*/
Expand Down
1 change: 0 additions & 1 deletion src/proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ void debug_mem_to_dcc(int);
int egg_strcatn(char *, const char *, size_t);
int my_strcpy(char *, char *);
void putlog(int type, char *chname, const char *format, ...) ATTRIBUTE_FORMAT(printf,3,4);
void flushlogs(void);
void check_logsize(void);
void splitc(char *, char *, char);
void splitcn(char *, char *, char, size_t);
Expand Down
2 changes: 0 additions & 2 deletions src/tcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ int must_be_owner = 1;
int quiet_reject = 1;
int copy_to_tmp = 1;
int max_socks = 100;
int log_interval = 15;
int par_telnet_flood = 1;
int quiet_save = 0;
int strtot = 0;
Expand Down Expand Up @@ -481,7 +480,6 @@ static tcl_ints def_tcl_ints[] = {
{"max-socks", &max_socks, 0},
{"max-logs", &max_logs, 0},
{"max-logsize", &max_logsize, 0},
{"log-interval", &log_interval, 0},
{"raw-log", &raw_log, 1},
{"protect-telnet", &protect_telnet, 0},
{"dcc-sanitycheck", &dcc_sanitycheck, 0},
Expand Down

0 comments on commit aad25fb

Please sign in to comment.