Skip to content

Commit

Permalink
[nrfconnect] Adapt Pigweed Logger to newer Zephyr versions (#19713)
Browse files Browse the repository at this point in the history
Initialization of the Pigwed HDLC-based Zephyr logging
backend would fail due to usage of deprecated backend
API.

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
  • Loading branch information
Damian-Nordic authored and pull[bot] committed Oct 10, 2023
1 parent 1340589 commit 1026356
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions examples/platform/nrfconnect/util/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,17 @@ void init(const log_backend *)
pw_sys_io_Init();
}

void putMessageSync(const log_backend *, log_msg_ids srcLevel, uint32_t timestamp, const char * fmt, va_list args)
void processMessage(const struct log_backend * const backend, union log_msg2_generic * msg)
{
int ret = k_sem_take(&sLoggerLock, K_FOREVER);
assert(ret == 0);

if (!sIsPanicMode)
log_backend_std_sync_string(&pigweedLogOutput, 0, srcLevel, timestamp, fmt, args);

k_sem_give(&sLoggerLock);
}

void putHexdumpSync(const log_backend *, log_msg_ids srcLevel, uint32_t timestamp, const char * metadata, const uint8_t * data,
uint32_t length)
{
int ret = k_sem_take(&sLoggerLock, K_FOREVER);
assert(ret == 0);
{
log_format_func_t outputFunc = log_format_func_t_get(LOG_OUTPUT_TEXT);

if (!sIsPanicMode)
log_backend_std_sync_hexdump(&pigweedLogOutput, 0, srcLevel, timestamp, metadata, data, length);
outputFunc(&pigweedLogOutput, &msg->log, log_backend_std_get_flags());
}

k_sem_give(&sLoggerLock);
}
Expand All @@ -134,11 +126,9 @@ void panic(const log_backend *)
}

const log_backend_api pigweedLogApi = {
.put = nullptr,
.put_sync_string = putMessageSync,
.put_sync_hexdump = putHexdumpSync,
.panic = panic,
.init = init,
.process = processMessage,
.panic = panic,
.init = init,
};

LOG_BACKEND_DEFINE(pigweedLogBackend, pigweedLogApi, /* autostart */ true);
Expand Down

0 comments on commit 1026356

Please sign in to comment.