g_return_if_fail(msg);
g_return_if_fail(g_muse_core_log);
+#if defined(HAVE_LOCALTIME_R)
+ struct tm newtime;
+#endif
+
+ struct tm* ptm;
struct timeval tv;
char time_buf[MUSE_LOG_LEN];
g_mutex_lock(&g_muse_core_log->log_lock);
gettimeofday(&tv, NULL);
- strftime(time_buf, sizeof(time_buf), "%m-%d %H:%M:%S", localtime(&(tv.tv_sec)));
+
+#if defined(HAVE_LOCALTIME_R)
+ ptm = localtime_r(&(tv.tv_sec), &newtime);
+#else
+ ptm = localtime(&(tv.tv_sec));
+#endif
+
+ strftime(time_buf, sizeof(time_buf), "%m-%d %H:%M:%S", ptm);
snprintf(g_muse_core_log->latest_msgs[g_muse_core_log->currnt_index], MUSE_LOG_MSG_LEN, "%s.%03ld %s ", time_buf, tv.tv_usec / 1000, msg);
g_muse_core_log->currnt_index = (g_muse_core_log->currnt_index + 1) % MUSE_LOG_MSG_NUM;