-/* Copyright (c) 1998, 2000, 2004 Free Software Foundation, Inc.
+/* Copyright (c) 1998-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1998.
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; version 2 of the License, or
+ (at your option) any later version.
- The GNU C Library is distributed in the hope that it will be useful,
+ This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#include <stdarg.h>
#include <stdio.h>
{
if (logfilename)
{
- dbgout = fopen (logfilename, "a");
+ dbgout = fopen64 (logfilename, "a");
return dbgout == NULL ? 0 : 1;
}
return 1;
dbg_log (const char *fmt,...)
{
va_list ap;
- char msg[512], msg2[512];
+ char msg2[512];
va_start (ap, fmt);
- vsnprintf (msg2, sizeof (msg), fmt, ap);
+ vsnprintf (msg2, sizeof (msg2), fmt, ap);
if (debug_level > 0)
{
- snprintf (msg, sizeof (msg), "%d: %s\n", getpid (), msg2);
+ time_t t = time (NULL);
+
+ struct tm now;
+ localtime_r (&t, &now);
+
+ char buf[256];
+ strftime (buf, sizeof (buf), "%c", &now);
+
+ char msg[1024];
+ snprintf (msg, sizeof (msg), "%s - %d: %s%s", buf, getpid (), msg2,
+ msg2[strlen (msg2) - 1] == '\n' ? "" : "\n");
if (dbgout)
{
fputs (msg, dbgout);
fputs (msg, stderr);
}
else
- {
- snprintf (msg, sizeof (msg), "%d: %s", getpid (), msg2);
- syslog (LOG_NOTICE, "%s", msg);
- }
+ syslog (LOG_NOTICE, "%d %s", getpid (), msg2);
+
va_end (ap);
}