logging: Add timestamp getter function part of internal API

Expose timestamp getter so it can be used, e.g. in the frontend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2022-03-31 13:25:41 +02:00 committed by Marti Bolivar
commit 8b0d429bfd
2 changed files with 15 additions and 4 deletions

View file

@ -105,6 +105,12 @@ bool z_log_msg2_pending(void);
*/ */
const char *z_log_get_tag(void); const char *z_log_get_tag(void);
/** @brief Get timestamp.
*
* @return Timestamp.
*/
log_timestamp_t z_log_timestamp(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -160,6 +160,11 @@ static log_timestamp_t dummy_timestamp(void)
return 0; return 0;
} }
log_timestamp_t z_log_timestamp(void)
{
return timestamp_func();
}
uint32_t z_log_get_s_mask(const char *str, uint32_t nargs) uint32_t z_log_get_s_mask(const char *str, uint32_t nargs)
{ {
char curr; char curr;
@ -611,6 +616,10 @@ void log_core_init(void)
if (IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING)) { if (IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING)) {
z_log_runtime_filters_init(); z_log_runtime_filters_init();
} }
if (IS_ENABLED(CONFIG_LOG_FRONTEND)) {
log_frontend_init();
}
} }
void log_init(void) void log_init(void)
@ -618,10 +627,6 @@ void log_init(void)
__ASSERT_NO_MSG(log_backend_count_get() < LOG_FILTERS_NUM_OF_SLOTS); __ASSERT_NO_MSG(log_backend_count_get() < LOG_FILTERS_NUM_OF_SLOTS);
int i; int i;
if (IS_ENABLED(CONFIG_LOG_FRONTEND)) {
log_frontend_init();
}
if (atomic_inc(&initialized) != 0) { if (atomic_inc(&initialized) != 0) {
return; return;
} }