Skip to content
7 changes: 4 additions & 3 deletions doc/sphinx_source/using/core.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Last revised: August 29, 2023
Last revised: Feb 25, 2025

=====================
Eggdrop Core Settings
Expand Down Expand Up @@ -185,8 +185,9 @@ logfile <logflags> <channel> "logs/logfile"

set timestamp-format "[%H:%M:%S]"
Set the following to the timestamp for the logfile entries. Popular times
might be "[%H:%M]" (hour, min), or "[%H:%M:%S]" (hour, min, sec).
Read 'man strftime' for more formatting options. Keep it below 32 chars.
might be "[%H:%M]" (hour, min), or "[%H:%M:%S]" (hour, min, sec). Read
'man strftime' for more formatting options. Additionally eggdrop supports "%f"
for milliseconds. Keep it below 32 chars.

set keep-all-logs 0
If you want to keep your logfiles forever, turn this setting on. All
Expand Down
7 changes: 4 additions & 3 deletions eggdrop.conf
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,9 @@ logfile mco * "logs/eggdrop.log"
set log-time 1

# Set the following to the timestamp for the logfile entries. Popular times
# might be "[%H:%M]" (hour, min), or "[%H:%M:%S]" (hour, min, sec).
# Read `man strftime' for more formatting options. Keep it below 32 chars.
# might be "[%H:%M]" (hour, min), or "[%H:%M:%S]" (hour, min, sec). Read
# 'man strftime' for more formatting options. Additionally eggdrop supports %f
# for milliseconds. Keep it below 32 chars.
set timestamp-format {[%H:%M:%S]}

# If you want to keep your logfiles forever, turn this setting on. All
Expand Down Expand Up @@ -1503,7 +1504,7 @@ set xfer-timeout 30
#loadmodule compress

# Allow compressed sending of user files? The user files are compressed with
# the compression level defined in `compress-level'.
# the compression level defined in 'compress-level'.
set share-compressed 1

# This is the default compression level used. These levels are the same as
Expand Down
32 changes: 23 additions & 9 deletions src/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,13 @@ void putlog (int type, char *chname, const char *format, ...)
{
static int inhere = 0;
int i, tsl = 0;
char s[LOGLINELEN], path[PATH_MAX], *out, ct[81], *s2, stamp[34];
char s[LOGLINELEN], path[PATH_MAX], *out, ct[81], *s2, stamp[34],
stamp2[sizeof stamp], *f, c;
va_list va;
time_t now2 = time(NULL);
static time_t now2_last = 0; /* cache expensive localtime() */
static struct tm t;
struct timeval tv;

if (now2 != now2_last) {
now2_last = now2;
Expand All @@ -528,12 +530,24 @@ void putlog (int type, char *chname, const char *format, ...)

/* Create the timestamp */
if (shtime) {
tsl = strftime(stamp, sizeof(stamp) - 2, log_ts, &t);
stamp[tsl++] = ' ';
stamp[tsl] = 0;
}
else
*stamp = '\0';
strlcpy(stamp, log_ts, sizeof stamp);

/* handle millisecond specifier %f */
if ((f = strstr(stamp, "%f")) && ((f - 1) != (strstr(stamp, "%%f")))) {
memmove(f + 3, f + 2, strlen(f + 2) + 1);
c = f[3]; /* save the char the following snprintf() will overwrite with
* null terminator
*/
gettimeofday(&tv, NULL);
snprintf(f, sizeof stamp - (f - stamp), "%03i", (int) tv.tv_usec / 1000);
f[3] = c;
}

tsl = strftime(stamp2, sizeof(stamp2) - 2, stamp, &t);
stamp2[tsl++] = ' ';
stamp2[tsl] = 0;
} else
*stamp2 = 0;

/* Format log entry at offset 'tsl,' then i can prepend the timestamp */
out = s + tsl;
Expand Down Expand Up @@ -565,7 +579,7 @@ void putlog (int type, char *chname, const char *format, ...)
}
/* Place the timestamp in the string to be printed */
if (out[0] && shtime) {
memcpy(s, stamp, tsl);
memcpy(s, stamp2, tsl);
out = s;
}
strcat(out, "\n");
Expand Down Expand Up @@ -599,7 +613,7 @@ void putlog (int type, char *chname, const char *format, ...)
* then reset repeats. We want the current time here,
* so put that in the file first.
*/
fprintf(logs[i].f, "%s", stamp);
fprintf(logs[i].f, "%s", stamp2);
fprintf(logs[i].f, MISC_LOGREPEAT, logs[i].repeats);
logs[i].repeats = 0;
/* No need to reset logs[i].szlast here
Expand Down
Loading