49 #ifndef included_clib_elog_h 50 #define included_clib_elog_h 110 char *enum_strings[];
299 word type_index, track_index;
328 e->
track = track_index;
439 #define __ELOG_TYPE_VAR(f) f 440 #define __ELOG_TRACK_VAR(f) f 442 #define ELOG_TYPE_DECLARE(f) static elog_event_type_t __ELOG_TYPE_VAR(f) 444 #define ELOG_TYPE_INIT_FORMAT_AND_FUNCTION(fmt,func) \ 445 { .format = fmt, .function = func, } 447 #define ELOG_TYPE_INIT(fmt) \ 448 ELOG_TYPE_INIT_FORMAT_AND_FUNCTION(fmt,(char *) __FUNCTION__) 450 #define ELOG_TYPE_DECLARE_HELPER(f,fmt,func) \ 451 static elog_event_type_t __ELOG_TYPE_VAR(f) = \ 452 ELOG_TYPE_INIT_FORMAT_AND_FUNCTION (fmt, func) 454 #define ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION(f,fmt) \ 455 ELOG_TYPE_DECLARE_HELPER (f, fmt, (char *) __FUNCTION__) 457 #define ELOG_TYPE_DECLARE_FORMAT(f,fmt) \ 458 ELOG_TYPE_DECLARE_HELPER (f, fmt, 0) 462 #define ELOG_TYPE(f,fmt) ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION(f,fmt) 463 #define ELOG_TYPE_D(f) ELOG_TYPE_DECLARE_FORMAT (f, #f " %d") 464 #define ELOG_TYPE_X(f) ELOG_TYPE_DECLARE_FORMAT (f, #f " 0x%x") 465 #define ELOG_TYPE_DF(f) ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (f, #f " %d") 466 #define ELOG_TYPE_XF(f) ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (f, #f " 0x%x") 467 #define ELOG_TYPE_FD(f) ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (f, #f " %d") 468 #define ELOG_TYPE_FX(f) ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (f, #f " 0x%x") 470 #define ELOG_TRACK_DECLARE(f) static elog_track_t __ELOG_TRACK_VAR(f) 471 #define ELOG_TRACK(f) ELOG_TRACK_DECLARE(f) = { .name = #f, } 474 #define ELOG(em,f,data) elog ((em), &__ELOG_TYPE_VAR(f), data) 475 #define ELOG_INLINE(em,f,data) elog_inline ((em), &__ELOG_TYPE_VAR(f), data) 478 #define ELOG_TRACK_DATA(em,f,track) \ 479 elog_data ((em), &__ELOG_TYPE_VAR(f), &__ELOG_TRACK_VAR(track)) 480 #define ELOG_TRACK_DATA_INLINE(em,f,track) \ 481 elog_data_inline ((em), &__ELOG_TYPE_VAR(f), &__ELOG_TRACK_VAR(track)) 484 #define ELOG_DATA(em,f) elog_data ((em), &__ELOG_TYPE_VAR (f), &(em)->default_track) 485 #define ELOG_DATA_INLINE(em,f) elog_data_inline ((em), &__ELOG_TYPE_VAR (f), &(em)->default_track) static void elog_enable_disable(elog_main_t *em, int is_enabled)
Enable or disable event logging.
uword * string_table_hash
char ** enum_strings_vector
String table as a vector constructed when type is registered.
void elog_resize(elog_main_t *em, u32 n_events)
char * format_one_elog_event(void *em_arg, void *ep_arg)
f64 time
Absolute time as floating point number in seconds.
elog_time_stamp_t serialize_time
static void * elog_data_inline(elog_main_t *em, elog_event_type_t *type, elog_track_t *track)
u32 elog_string(elog_main_t *em, char *format,...)
add a string to the event-log string table
u16 event_type
Event type index.
u64 time_cycles
Absolute time stamp in CPU clock cycles.
void serialize_elog_main(serialize_main_t *m, va_list *va)
u8 * format_elog_event(u8 *s, va_list *va)
static u64 clib_cpu_time_now(void)
word elog_event_type_register(elog_main_t *em, elog_event_type_t *t)
register an event type
char * format
Format string.
void unserialize_elog_main(serialize_main_t *m, va_list *va)
u8 data[20]
20-bytes of data follows, pads to 32 bytes.
u32 n_enum_strings
Number of elements in string enum table.
u8 * format_elog_track_name(u8 *s, va_list *va)
static void * elog_event_data_not_inline(elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u64 cpu_time)
Allocate an event to be filled in by the caller, non-inline.
static void elog_disable_after_events(elog_main_t *em, uword n)
disable logging after specified number of ievents have been logged.
u32 type_index_plus_one
Type index plus one assigned to this type.
description fragment has unexpected format
__clib_export void serialize_close(serialize_main_t *m)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
uword * lock
SMP lock, non-zero means locking required.
char * format_args
Specifies how arguments to format are parsed from event data.
uword * event_type_by_format
Hash table mapping type format to type index.
clib_error_t * elog_read_file_not_inline(elog_main_t *em, char *clib_file)
static clib_error_t * elog_write_file(elog_main_t *em, char *clib_file, int flush_ring)
elog_event_type_t * event_types
Vector of event types.
void elog_init(elog_main_t *em, u32 n_events)
static void elog_inline(elog_main_t *em, elog_event_type_t *type, u32 data)
Log a single-datum event, inline version.
char * name
Track name vector.
void elog_alloc(elog_main_t *em, u32 n_events)
elog_event_t * event_ring
Vector of events (circular buffer).
f64 nsec_per_cpu_clock
Use serialize_time and init_time to give estimate for cpu clock frequency.
static void elog(elog_main_t *em, elog_event_type_t *type, u32 data)
Log a single-datum event.
word elog_track_register(elog_main_t *em, elog_track_t *t)
register an event track
clib_error_t * elog_write_file_not_inline(elog_main_t *em, char *clib_file, int flush_ring)
__clib_export void unserialize_close(serialize_main_t *m)
static uword elog_n_events_in_buffer(elog_main_t *em)
Return number of events in the event-log buffer.
u8 * format_elog_track(u8 *s, va_list *args)
__clib_export clib_error_t * serialize(serialize_main_t *m,...)
__clib_export clib_error_t * unserialize_open_clib_file(serialize_main_t *m, char *file)
u32 track_index_plus_one
Set to one when track has been added to main structure.
u32 n_total_events_disable_limit
When count reaches limit logging is disabled.
u64 os_nsec
OS timer in nano secs since epoch 3/30/2017, see elog_time_now()
void elog_time_now(elog_time_stamp_t *et)
void elog_merge(elog_main_t *dst, u8 *dst_tag, elog_main_t *src, u8 *src_tag, f64 align_tweak)
static void elog_reset_buffer(elog_main_t *em)
Reset the event buffer.
uword event_ring_size
Power of 2 number of elements in ring.
u64 cpu
CPU cycle counter.
u16 track
Track for this event.
clib_time_t cpu_timer
Place holder for CPU clock frequency.
elog_event_t placeholder_event
Dummy event to use when logger is disabled.
static uword is_pow2(uword x)
#define clib_atomic_fetch_add(a, b)
elog_event_t * events
Vector of events converted to generic form after collection.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static uword elog_is_enabled(elog_main_t *em)
event logging enabled predicate
elog_track_t * tracks
Vector of tracks.
static void elog_track(elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u32 data)
Log a single-datum event to a specific track, non-inline version.
static void * elog_data(elog_main_t *em, elog_event_type_t *type, elog_track_t *track)
char * string_table
Events may refer to strings in string table.
static clib_error_t * elog_read_file(elog_main_t *em, char *clib_file)
elog_track_t default_track
Default track.
u32 n_total_events
Total number of events in buffer.
elog_event_t * elog_get_events(elog_main_t *em)
convert event ring events to events, and return them as a vector.
elog_event_t * elog_peek_events(elog_main_t *em)
convert event ring events to events, and return them as a vector.
static void elog_track_inline(elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u32 data)
Log a single-datum event to a specific track.
__clib_export clib_error_t * unserialize(serialize_main_t *m,...)
void * elog_event_data(elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u64 cpu_time)
static void * elog_event_data_inline(elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u64 cpu_time)
Allocate an event to be filled in by the caller.
__clib_export clib_error_t * serialize_open_clib_file(serialize_main_t *m, char *file)
static uword elog_buffer_capacity(elog_main_t *em)
Return number of events which can fit in the event buffer.
static void elog_disable_trigger(elog_main_t *em)