Squashed 'lib/pinelog/' changes from bdee493..27a5eab

27a5eab Use localtime_r instead of localtime

git-subtree-dir: lib/pinelog
git-subtree-split: 27a5eab8b75c18d13ec0b69c01deaa82c996cf57
reverse-scroll
nirenjan 2021-08-03 11:26:06 -07:00
parent 8db1be2ba8
commit dc72e43f1e
1 changed files with 6 additions and 3 deletions

View File

@ -180,12 +180,15 @@ void pinelog_log_message(int level, const char *file, int line, const char *fmt,
#if PINELOG_SHOW_DATE #if PINELOG_SHOW_DATE
do { do {
time_t t; time_t t;
struct tm tm1;
struct tm *tmp; struct tm *tmp;
char date_string[30]; char date_string[30];
t = time(NULL); t = time(NULL);
tmp = localtime(&t); tmp = localtime_r(&t, &tm1);
if (tmp != NULL) {
strftime(date_string, sizeof(date_string), "%F %T ", tmp); strftime(date_string, sizeof(date_string), "%F %T ", tmp);
fputs(date_string, output_stream); fputs(date_string, output_stream);
}
} while (0); } while (0);
#endif #endif