本页内容

C

实现日志记录支持

打印日志

实现PlatformContext::consoleWrite 以支持消息输出。该方法由Qt Quick Ultralite内核调用以输出单个字符,并作为Qul::PlatformInterface::log 的输出。

实现示例

void ExamplePlatform::consoleWrite(char character) {
    // Write the charactor to your boards output device
}

注意: 出于性能考虑,建议 进行某种形式的缓冲处理,而不是将每个缓冲区直接写入设备。

示例平台在example-baremetal/platform_context.cpp 中展示了如何实现缓冲。

从平台适配中打印消息

您可以在开发过程中使用Qul::PlatformInterface::log 来打印消息。

Qul::PlatformInterface::log("Qt for MCUs!\r\n");

此外还提供了一个 C API,用于支持从 C 代码中打印日志。qul_printf 和qul_vprintf 均使用PlatformContext::consoleWrite 作为输出。

qul_printf("Ultimate performance. Tiny footprint.\r\n");

另请参阅 qul_snprintf()、qul_sprintf() 和qul_vsnprintf()。

在某些 Qt 许可下可用。
了解更多信息。