]> the.earth.li Git - onak.git/blobdiff - log.c
Switch to re-entrant versions of *time functions
[onak.git] / log.c
diff --git a/log.c b/log.c
index 8ab5e96526b916283efe06e01b966c9eed7534d0..7c6f2eeee5312e3e6e5dfd21fc4b976db5d2bc15 100644 (file)
--- a/log.c
+++ b/log.c
@@ -13,8 +13,7 @@
  * more details.
  *
  * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #include <stdarg.h>
@@ -134,19 +133,19 @@ loglevels getlogthreshold(void)
  */
 static void vflog(FILE *logfile, const char *format, va_list ap)
 {
-       struct tm *timestamp = NULL;
-       time_t     timer = 0;
+       struct tm timestamp;
+       time_t    timer = 0;
 
        timer = time(NULL);
-       timestamp = localtime(&timer);
+       localtime_r(&timer, &timestamp);
 
        fprintf(logfile, "[%02d/%02d/%4d %02d:%02d:%02d] %s[%d]: ",
-                       timestamp->tm_mday,
-                       timestamp->tm_mon + 1,
-                       timestamp->tm_year + 1900,
-                       timestamp->tm_hour,
-                       timestamp->tm_min,
-                       timestamp->tm_sec,
+                       timestamp.tm_mday,
+                       timestamp.tm_mon + 1,
+                       timestamp.tm_year + 1900,
+                       timestamp.tm_hour,
+                       timestamp.tm_min,
+                       timestamp.tm_sec,
                        (logappname == NULL) ? "" : logappname,
                        getpid());
        vfprintf(logfile, format, ap);