16 #include <flecsi-config.h> 18 #if defined(FLECSI_ENABLE_FLOG) 20 #if defined(FLOG_ENABLE_MPI) 25 #error "Need implementation for Windows" 40 #ifndef FLOG_MAX_MESSAGE_SIZE 41 #define FLOG_MAX_MESSAGE_SIZE 1024 44 #ifndef FLOG_MAX_PACKET_BUFFER 45 #define FLOG_MAX_PACKET_BUFFER 1024 49 #ifndef FLOG_PACKET_FLUSH_INTERVAL 50 #define FLOG_PACKET_FLUSH_INTERVAL 100000 61 static constexpr
size_t sec_bytes =
sizeof(time_t);
62 static constexpr
size_t usec_bytes =
sizeof(suseconds_t);
63 static constexpr
size_t packet_bytes =
64 sec_bytes + usec_bytes + FLOG_MAX_MESSAGE_SIZE;
66 packet_t(
const char * msg =
nullptr) {
68 if(gettimeofday(&stamp, NULL)) {
69 std::cerr <<
"FLOG: call to gettimeofday failed!!! " << __FILE__
70 << __LINE__ << std::endl;
75 bytes_.data(),
reinterpret_cast<const char *
>(&stamp.tv_sec), sec_bytes);
77 strncpy(bytes_.data() + sec_bytes,
78 reinterpret_cast<const char *
>(&stamp.tv_usec),
81 std::ostringstream oss;
84 strcpy(bytes_.data() + sec_bytes + usec_bytes, oss.str().c_str());
87 time_t
const & seconds()
const {
88 return *
reinterpret_cast<time_t
const *
>(bytes_.data());
91 suseconds_t
const & useconds()
const {
92 return *
reinterpret_cast<suseconds_t
const *
>(bytes_.data() + sec_bytes);
95 const char * message() {
96 return bytes_.data() + sec_bytes + usec_bytes;
99 const char * data()
const {
100 return bytes_.data();
103 static constexpr
size_t bytes() {
104 return sec_bytes + usec_bytes + FLOG_MAX_MESSAGE_SIZE;
107 bool operator<(
packet_t const & b) {
108 return this->seconds() == b.seconds() ? this->useconds() < b.useconds()
109 : this->seconds() < b.seconds();
113 std::array<char, packet_bytes> bytes_;
120 #endif // FLECSI_ENABLE_FLOG
Definition: control.hh:31