3232#ifndef lnav_log_format_fwd_hh
3333#define lnav_log_format_fwd_hh
3434
35+ #include < chrono>
36+ #include < cstdint>
37+ #include < optional>
3538#include < utility>
3639
3740#include < sys/types.h>
41+ #include < time.h>
3842
3943#include " ArenaAlloc/arenaalloc.h"
4044#include " base/file_range.hh"
45+ #include " base/intern_string.hh"
46+ #include " base/log_level_enum.hh"
4147#include " base/map_util.hh"
4248#include " base/string_attr_type.hh"
4349#include " byte_array.hh"
@@ -153,11 +159,12 @@ public:
153159 ll_sub_offset (0 ), ll_valid_utf(1 ), ll_level(lev), ll_module_id(mod),
154160 ll_meta_mark(0 ), ll_expr_mark(0 )
155161 {
156- memset (this ->ll_schema , 0 , sizeof (this ->ll_schema ));
162+ this ->ll_schema [0 ] = 0 ;
163+ this ->ll_schema [1 ] = 0 ;
157164 }
158165
159166 logline (file_off_t off,
160- const struct timeval & tv,
167+ const timeval& tv,
161168 log_level_t lev,
162169 uint8_t mod = 0 ,
163170 uint8_t opid = 0 )
@@ -166,7 +173,8 @@ public:
166173 ll_expr_mark(0 )
167174 {
168175 this ->set_time (tv);
169- memset (this ->ll_schema , 0 , sizeof (this ->ll_schema ));
176+ this ->ll_schema [0 ] = 0 ;
177+ this ->ll_schema [1 ] = 0 ;
170178 }
171179
172180 /* * @return The offset of the line in the file. */
@@ -192,10 +200,10 @@ public:
192200
193201 void to_exttm (struct exttm & tm_out) const
194202 {
195- auto secs = static_cast <time_t >(
203+ const auto secs = static_cast <time_t >(
196204 this ->get_time <std::chrono::seconds>().count ());
197205
198- tm_out. et_tm = * gmtime (&secs);
206+ gmtime_r (&secs, &tm_out. et_tm );
199207 tm_out.et_nsec
200208 = this ->get_subsecond_time <std::chrono::nanoseconds>().count ();
201209 }
@@ -216,10 +224,7 @@ public:
216224 };
217225 }
218226
219- void set_time (const timeval& tv)
220- {
221- this ->ll_time = to_us (tv);
222- }
227+ void set_time (const timeval& tv) { this ->ll_time = to_us (tv); }
223228
224229 template <typename T>
225230 void set_subsecond_time (T sub)
@@ -340,8 +345,6 @@ public:
340345 memcpy (this ->ll_schema , ba.in (), sizeof (this ->ll_schema ));
341346 }
342347
343- char get_schema () const { return this ->ll_schema [0 ]; }
344-
345348 /* *
346349 * Perform a partial match of the given schema against this log line.
347350 * Storing the full schema is not practical, so we just keep the first four
0 commit comments