static void _lg_fmtout( struct log_trace_session *session, const char *fmt, va_list argptr) { /* 1 for ']' */ static char _trace_buf[1+LOG_TRACE_BUFSZ]; char *ptr; rt_size_t length; RT_ASSERT(session); RT_ASSERT(fmt); rt_snprintf(_trace_buf, sizeof(_trace_buf), "[%08x][", rt_tick_get()); if (_traceout_device != RT_NULL) { rt_device_write(_traceout_device, -1, _trace_buf, 11); rt_device_write(_traceout_device, -1, session->id.name, _idname_len(session->id.num)); } _trace_buf[0] = ']'; ptr = &_trace_buf[1]; length = rt_vsnprintf(ptr, LOG_TRACE_BUFSZ, fmt, argptr); if (length >= LOG_TRACE_BUFSZ) length = LOG_TRACE_BUFSZ - 1; if (_traceout_device != RT_NULL) { rt_device_write(_traceout_device, -1, _trace_buf, length + 1); } }
void hdp_client_log(const char *fmt, ...) { va_list args; rt_size_t length; static char rt_log_buf[MAX_LOG_LEN]={0}; rt_uint16_t old_flag = rcuDevice->flag; if(rcuDevice==NULL) return; va_start(args, fmt); /* the return value of vsnprintf is the number of bytes that would be * written to buffer had if the size of the buffer been sufficiently * large excluding the terminating null byte. If the output string * would be larger than the rt_log_buf, we have to adjust the output * length. */ length = rt_vsnprintf(rt_log_buf, sizeof(rt_log_buf) - 1, fmt, args); if (length > MAX_LOG_LEN - 1) length = MAX_LOG_LEN - 1; rcuDevice->flag |= RT_DEVICE_FLAG_STREAM; rt_device_write(rcuDevice, 0, rt_log_buf, length); rcuDevice->flag = old_flag; va_end(args); }
void __wrap_rtl_printf(const char *fmt, ...) { va_list args; rt_size_t length; static char rt_log_buf[RT_CONSOLEBUF_SIZE]; va_start(args, fmt); /* the return value of vsnprintf is the number of bytes that would be * written to buffer had if the size of the buffer been sufficiently * large excluding the terminating null byte. If the output string * would be larger than the rt_log_buf, we have to adjust the output * length. */ length = rt_vsnprintf(rt_log_buf, sizeof(rt_log_buf) - 1, fmt, args); if (length > RT_CONSOLEBUF_SIZE - 1) length = RT_CONSOLEBUF_SIZE - 1; rt_kprintf("%s", rt_log_buf); va_end(args); }