#include "osal_log.h"
#include "osal_config.h"
#include <rtthread.h>
#include <stdarg.h>

void osal_kprintf(const char *fmt, ...)
{
    va_list args;
    char log_buf[OSAL_LOG_BUF_SIZE];
    rt_int32_t length;
    
    va_start(args, fmt);
    /* rt_vsnprintf is provided by RT-Thread kservice */
    length = rt_vsnprintf(log_buf, sizeof(log_buf) - 1, fmt, args);
    if (length > 0)
    {
        log_buf[length] = '\0';
        rt_kprintf("%s", log_buf);
    }
    else
    {
        rt_kprintf("osal_kprintf: vsnprintf failed or empty\n");
    }
    va_end(args);
}
