@@ -67,11 +67,19 @@ static int zlog_spec_write_time_internal(zlog_spec_t * a_spec, zlog_thread_t * a
6767 if ( use_utc ) {
6868 time = & (a_thread -> event -> time_utc );
6969 time_sec = & (a_thread -> event -> time_utc_sec );
70+ #ifdef _WIN32
71+ time_stamp_convert_function = gmtime_s ;
72+ #else
7073 time_stamp_convert_function = gmtime_r ;
74+ #endif
7175 } else {
7276 time = & (a_thread -> event -> time_local );
7377 time_sec = & (a_thread -> event -> time_local_sec );
78+ #ifdef _WIN32
79+ time_stamp_convert_function = localtime_s ;
80+ #else
7481 time_stamp_convert_function = localtime_r ;
82+ #endif
7583 }
7684
7785 /* the event meet the 1st time_spec in his life cycle */
@@ -264,13 +272,15 @@ static int zlog_spec_write_tid_long(zlog_spec_t * a_spec, zlog_thread_t * a_thre
264272 return zlog_buf_append (a_buf , a_thread -> event -> tid_str , a_thread -> event -> tid_str_len );
265273}
266274
275+ #if defined __linux__ || __APPLE__
267276static int zlog_spec_write_ktid (zlog_spec_t * a_spec , zlog_thread_t * a_thread , zlog_buf_t * a_buf )
268277{
269278
270279 /* don't need to get ktid again, as tmap_new_thread fetched it already */
271280 /* and fork not change tid */
272281 return zlog_buf_append (a_buf , a_thread -> event -> ktid_str , a_thread -> event -> ktid_str_len );
273282}
283+ #endif
274284
275285static int zlog_spec_write_level_lowercase (zlog_spec_t * a_spec , zlog_thread_t * a_thread , zlog_buf_t * a_buf )
276286{
@@ -647,9 +657,11 @@ zlog_spec_t *zlog_spec_new(char *pattern_start, char **pattern_next, int *time_c
647657 case 'H' :
648658 a_spec -> write_buf = zlog_spec_write_hostname ;
649659 break ;
660+ #if defined __linux__ || __APPLE__
650661 case 'k' :
651662 a_spec -> write_buf = zlog_spec_write_ktid ;
652663 break ;
664+ #endif
653665 case 'L' :
654666 a_spec -> write_buf = zlog_spec_write_srcline ;
655667 break ;
0 commit comments