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