diff options
| author | trystan trystan@31f1291d-b8d6-0310-a050-a5561fc1590b <trystan trystan@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2005-02-06 19:18:15 +0000 |
|---|---|---|
| committer | trystan trystan@31f1291d-b8d6-0310-a050-a5561fc1590b <trystan trystan@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2005-02-06 19:18:15 +0000 |
| commit | 9b3a357193a020c53624b29f84e0bca4795722f0 (patch) | |
| tree | be1a500c8a469dad8164a72d1266780ac8c28510 /src/log.c | |
| parent | f8ac398b86ea6a26dba62064d9810796466e4118 (diff) | |
BUILD : 1.7.8 (565) BUGS : 293 NOTES : Merge of Win32 branch into the main, support for Unreal +I, German language updated, fixed bug vidents not updating, Setting and Removal of sqlines on forbid or drop
git-svn-id: svn://svn.anope.org/anope/trunk@567 31f1291d-b8d6-0310-a050-a5561fc1590b
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@417 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/log.c')
| -rw-r--r-- | src/log.c | 49 |
1 files changed, 49 insertions, 0 deletions
@@ -58,7 +58,11 @@ static void remove_log(void) if (!get_logname(name, sizeof(name), &tm)) return; +#ifndef _WIN32 unlink(name); +#else + DeleteFile(name); +#endif } /*************************************************************************/ @@ -314,3 +318,48 @@ void fatal_perror(const char *fmt, ...) } /*************************************************************************/ + +/* Same thing, but do it like perror(). + * This is for socket errors. On *nix, it works just like fatal_perror, + * on Win32, it uses the socket error code and formatting functions. + */ + +void fatal_sockerror(const char *fmt, ...) +{ + va_list args; + time_t t; + struct tm tm; + char buf[256], buf2[4096]; + int errno_save = ano_sockgeterr(); + + checkday(); + + va_start(args, fmt); + time(&t); + tm = *localtime(&t); +#if HAVE_GETTIMEOFDAY + if (debug) { + char *s; + struct timeval tv; + gettimeofday(&tv, NULL); + strftime(buf, sizeof(buf) - 1, "[%b %d %H:%M:%S", &tm); + s = buf + strlen(buf); + s += snprintf(s, sizeof(buf) - (s - buf), ".%06d", tv.tv_usec); + strftime(s, sizeof(buf) - (s - buf) - 1, " %Y] ", &tm); + } else { +#endif + strftime(buf, sizeof(buf) - 1, "[%b %d %H:%M:%S %Y] ", &tm); +#if HAVE_GETTIMEOFDAY + } +#endif + vsnprintf(buf2, sizeof(buf2), fmt, args); + if (logfile) + fprintf(logfile, "%sFATAL: %s: %s\n", buf, buf2, + ano_sockstrerror(errno_save)); + if (stderr) + fprintf(stderr, "%sFATAL: %s: %s\n", buf, buf2, + ano_sockstrerror(errno_save)); + if (servsock >= 0) + wallops(NULL, "FATAL ERROR! %s: %s", buf2, strerror(errno_save)); + exit(1); +} |
