32
32
#include <fluent-bit/flb_config.h>
33
33
#include <fluent-bit/flb_worker.h>
34
34
#include <fluent-bit/flb_mem.h>
35
+ #include "cfl/cfl_time.h"
35
36
36
37
#ifdef WIN32
37
38
#include <winsock.h>
@@ -46,6 +47,8 @@ extern struct flb_aws_error_reporter *error_reporter;
46
47
47
48
FLB_TLS_DEFINE (struct flb_log , flb_log_ctx )
48
49
50
+ #define NANOSECONDS_IN_SECOND 1000000000
51
+
49
52
/* Simple structure to dispatch messages to the log collector */
50
53
struct log_message {
51
54
size_t size ;
@@ -564,31 +567,12 @@ struct flb_log *flb_log_create(struct flb_config *config, int type,
564
567
return log ;
565
568
}
566
569
567
- #ifdef _WIN32
568
- #include "windows.h"
569
-
570
- #define WINDOWS_EPOCH_OFFSET 116444736000000000ULL
571
-
572
570
void get_current_time (struct timespec * ts )
573
571
{
574
- FILETIME ft ;
575
- ULARGE_INTEGER li ;
576
-
577
- GetSystemTimeAsFileTime (& ft );
578
- li .LowPart = ft .dwLowDateTime ;
579
- li .HighPart = ft .dwHighDateTime ;
580
-
581
- // Convert to Unix epoch
582
- uint64_t time = (li .QuadPart - WINDOWS_EPOCH_OFFSET ) / 10 ;
583
- ts -> tv_sec = time / 1000000 ;
584
- ts -> tv_nsec = (time % 1000000 ) * 1000 ;
572
+ uint64_t now = cfl_time_now ();
573
+ ts -> tv_sec = now / NANOSECONDS_IN_SECOND ;
574
+ ts -> tv_nsec = now % NANOSECONDS_IN_SECOND ;
585
575
}
586
- #else
587
- void get_current_time (struct timespec * ts )
588
- {
589
- clock_gettime (CLOCK_REALTIME , ts );
590
- }
591
- #endif
592
576
593
577
int flb_log_construct (struct log_message * msg , int * ret_len ,
594
578
int type , const char * file , int line , const char * fmt , va_list * args )
0 commit comments