@@ -41,7 +41,7 @@ static struct rt_device _log_device;
4141static rt_device_t _traceout_device = RT_NULL ;
4242
4343/* define a default lg session. The name is empty. */
44- static struct log_trace_session _def_session = {{"\0" }, LOG_TRACE_LEVEL_INFO };
44+ static struct log_trace_session _def_session = {{"\0" }, LOG_TRACE_LEVEL_DEFAULT };
4545static const struct log_trace_session * _the_sessions [LOG_TRACE_MAX_SESSION ] = {& _def_session };
4646/* there is a default session at least */
4747static rt_uint16_t _the_sess_nr = 1 ;
@@ -267,16 +267,31 @@ void __logtrace_vfmtout(const struct log_trace_session *session,
267267 RT_ASSERT (session );
268268 RT_ASSERT (fmt );
269269
270- rt_snprintf ( _trace_buf , sizeof ( _trace_buf ), "[%08x][" , rt_tick_get ());
271- if (_traceout_device != RT_NULL )
270+ /* it's default session */
271+ if (session -> id . name [ 0 ] == '\0' )
272272 {
273- rt_device_write (_traceout_device , -1 , _trace_buf , 11 );
274- rt_device_write (_traceout_device , -1 ,
275- session -> id .name , _idname_len (session -> id .num ));
273+ rt_snprintf (_trace_buf , sizeof (_trace_buf ), "[%08x]" , rt_tick_get ());
274+ if (_traceout_device != RT_NULL )
275+ {
276+ rt_device_write (_traceout_device , -1 , _trace_buf , 10 );
277+ }
278+
279+ ptr = & _trace_buf [0 ];
280+ }
281+ else
282+ {
283+ rt_snprintf (_trace_buf , sizeof (_trace_buf ), "[%08x][" , rt_tick_get ());
284+ if (_traceout_device != RT_NULL )
285+ {
286+ rt_device_write (_traceout_device , -1 , _trace_buf , 11 );
287+ rt_device_write (_traceout_device , -1 ,
288+ session -> id .name , _idname_len (session -> id .num ));
289+ }
290+
291+ _trace_buf [0 ] = ']' ;
292+ ptr = & _trace_buf [1 ];
276293 }
277294
278- _trace_buf [0 ] = ']' ;
279- ptr = & _trace_buf [1 ];
280295 length = rt_vsnprintf (ptr , LOG_TRACE_BUFSZ , fmt , argptr );
281296
282297 if (length >= LOG_TRACE_BUFSZ )
0 commit comments