mirror of https://code.videolan.org/videolan/vlc
tracer: move tick conversion in modules
This commit is contained in:
parent
31c7dc1204
commit
425f4424d6
|
@ -43,17 +43,17 @@
|
|||
enum vlc_tracer_value
|
||||
{
|
||||
VLC_TRACER_INT,
|
||||
VLC_TRACER_TICK,
|
||||
VLC_TRACER_STRING
|
||||
};
|
||||
|
||||
typedef union
|
||||
{
|
||||
int64_t integer;
|
||||
vlc_tick_t tick;
|
||||
const char *string;
|
||||
} vlc_tracer_value_t;
|
||||
|
||||
#define VLC_TRACER_TIME_FROM_TICK(ts) NS_FROM_VLC_TICK(ts)
|
||||
|
||||
/**
|
||||
* Trace message
|
||||
*/
|
||||
|
@ -102,8 +102,8 @@ VLC_API void vlc_tracer_Trace(struct vlc_tracer *tracer, ...);
|
|||
static inline struct vlc_tracer_entry vlc_tracer_entry_FromTick(const char *key, vlc_tick_t value)
|
||||
{
|
||||
vlc_tracer_value_t tracer_value;
|
||||
tracer_value.integer = VLC_TRACER_TIME_FROM_TICK(value);
|
||||
struct vlc_tracer_entry trace = { key, tracer_value, VLC_TRACER_INT };
|
||||
tracer_value.integer = value;
|
||||
struct vlc_tracer_entry trace = { key, tracer_value, VLC_TRACER_TICK };
|
||||
return trace;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
|
||||
#define JSON_FILENAME "vlc-log.json"
|
||||
|
||||
#define TIME_FROM_TICK(ts) NS_FROM_VLC_TICK(ts)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
FILE *stream;
|
||||
|
@ -161,7 +163,7 @@ static void TraceJson(void *opaque, va_list entries)
|
|||
|
||||
flockfile(stream);
|
||||
JsonStartObjectSection(stream, NULL);
|
||||
JsonPrintKeyValueNumber(stream, "Timestamp", VLC_TRACER_TIME_FROM_TICK(vlc_tick_now()));
|
||||
JsonPrintKeyValueNumber(stream, "Timestamp", TIME_FROM_TICK(vlc_tick_now()));
|
||||
fputc(',', stream);
|
||||
|
||||
JsonStartObjectSection(stream, "Body");
|
||||
|
@ -174,6 +176,10 @@ static void TraceJson(void *opaque, va_list entries)
|
|||
case VLC_TRACER_INT:
|
||||
JsonPrintKeyValueNumber(stream, entry.key, entry.value.integer);
|
||||
break;
|
||||
case VLC_TRACER_TICK:
|
||||
JsonPrintKeyValueNumber(stream, entry.key,
|
||||
TIME_FROM_TICK(entry.value.tick));
|
||||
break;
|
||||
case VLC_TRACER_STRING:
|
||||
JsonPrintKeyValueLabel(stream, entry.key, entry.value.string);
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue