Skip to content

Commit

Permalink
remove quick-logs option
Browse files Browse the repository at this point in the history
Found by: michaelortmann
Patch by: michaelortmann
Fixes: #1449

Line-buffer instead
  • Loading branch information
michaelortmann authored Jan 14, 2024
1 parent d11609c commit 40f93b8
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 78 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 @@ -158,7 +158,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 -t 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
6 changes: 0 additions & 6 deletions eggdrop.conf
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,6 @@ set max-logs 20
# have keep-all-logs 0 (OFF).
set max-logsize 0

# This could be good if you have had problem with the logfile filling
# your quota/hard disk or if you log +p and publish it to the web and
# 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 mem usage).
set quick-logs 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 'v',
# raw incoming botnet traffic via console/log mode 't', raw outgoing botnet
Expand Down
1 change: 0 additions & 1 deletion help/core.help
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ default-flags
log-time
timestamp-format
max-logsize
quick-logs
logfile-suffix
quiet-save
remote-boots
Expand Down
7 changes: 0 additions & 7 deletions help/set/cmds1.help
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,6 @@
This value is in kilobytes, so '550' would mean cycle logs when it
reaches the size of 550 kilobytes. Note that this only works if you
have keep-all-logs 0 (OFF).
%{help=set quick-logs}%{+n}
### %bset quick-logs%b <0/1>
This could be good if you have had problem with the logfile
filling your quota/hard disk or if you log +p and publish it to
the web and 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 mem usage).
%{help=set logfile-suffix}%{+n}
### %bset logfile-suffix%b <suffix>
If keep-all-logs is 1, this setting will define the suffix of the
Expand Down
16 changes: 3 additions & 13 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@
#endif

extern char origbotname[], botnetnick[];
extern int dcc_total, conmask, cache_hit, cache_miss, max_logs, quick_logs,
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 @@ -179,7 +178,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 @@ -589,7 +587,6 @@ static void core_secondly()
if (nowmins > lastmin) {
memcpy(&nowtm, localtime(&now), sizeof(struct tm));
i = 0;

/* Once a minute */
++lastmin;
call_hook(HOOK_MINUTELY);
Expand All @@ -610,10 +607,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 (!quick_logs) {
flushlogs();
check_logsize();
}

if (!miltime) { /* At midnight */
char s[25];
int j;
Expand Down Expand Up @@ -661,10 +655,7 @@ static void core_minutely()
{
check_tcl_time_and_cron(&nowtm);
do_check_timers(&timer);
if (quick_logs != 0) {
flushlogs();
check_logsize();
}
check_logsize();
}

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

flushlogs();
kill_tcl();
init_tcl(argc, argv);
init_language(0);
Expand Down
45 changes: 5 additions & 40 deletions src/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ extern struct chanset_t *chanset;

extern char helpdir[], version[], origbotname[], botname[], admin[], network[],
motdfile[], ver[], botnetnick[], bannerfile[], textdir[];
extern int backgrd, con_chan, term_z, use_stderr, dcc_total, keep_all_logs,
quick_logs;
extern int backgrd, con_chan, term_z, use_stderr, dcc_total, keep_all_logs;

extern time_t now;
extern Tcl_Interp *interp;
Expand Down Expand Up @@ -579,9 +578,10 @@ void putlog (int type, char *chname, const char *format, ...)
/* Open this logfile */
if (keep_all_logs) {
snprintf(path, sizeof path, "%s%s", logs[i].filename, ct);
logs[i].f = fopen(path, "a");
} else
logs[i].f = fopen(logs[i].filename, "a");
if ((logs[i].f = fopen(path, "a")))
setvbuf(logs[i].f, NULL, _IOLBF, 0); /* line buffered */
} else if ((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 @@ -653,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 @@ -678,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 @@ -693,39 +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) && quick_logs) {
/* Repeat.. if quicklogs used then 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 @@ -87,7 +87,6 @@ int allow_dk_cmds = 1;
int must_be_owner = 1;
int quiet_reject = 1;
int max_socks = 100;
int quick_logs = 0;
int par_telnet_flood = 1;
int quiet_save = 0;
int strtot = 0;
Expand Down Expand Up @@ -480,7 +479,6 @@ static tcl_ints def_tcl_ints[] = {
{"max-socks", &max_socks, 0},
{"max-logs", &max_logs, 0},
{"max-logsize", &max_logsize, 0},
{"quick-logs", &quick_logs, 0},
{"raw-log", &raw_log, 1},
{"protect-telnet", &protect_telnet, 0},
{"dcc-sanitycheck", &dcc_sanitycheck, 0},
Expand Down

0 comments on commit 40f93b8

Please sign in to comment.