voidlog_print(enumlog_color color,constchar*file,intline,constchar*func,constchar* fmt, ...) { va_list ap; charbuf[LOG_BUF_SIZE] = {0}; longlongtime = s_get_sys_time_ms; va_start(ap, fmt); vsnprintf(buf,sizeof(buf), fmt, ap); va_end(ap); switch(color) { caseCOLOR_NUL...
void log_print(enum log_color color, const char *file, int line, const char *func, const char* fmt, ...) { va_list ap; char buf[LOG_BUF_SIZE] = {0}; long long time = s_get_sys_time_ms(); va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); swi...
packagemainimport("bytes""fmt""log")type User struct{Name string Age int}funcmain(){u:=User{Name:"dj",Age:18,}buf:=&bytes.Buffer{}logger:=log.New(buf,"",log.Lshortfile|log.LstdFlags)logger.Printf("%s login, age:%d",u.Name,u.Age)fmt.Print(buf.String())} log.New接受三个参数:...
voidlog_print(enumlog_colorcolor,constchar*file,intline,constchar*func,constchar*fmt,...) { va_listap; charbuf[LOG_BUF_SIZE]={0}; longlongtime=s_get_sys_time_ms(); va_start(ap,fmt); vsnprintf(buf,sizeof(buf),fmt,ap); va_end(ap); switch(color) { caseCOLOR_NULL: printf("<...
fmt.Print(buf.String()) } log.New接受三个参数: io.Writer:日志都会写到这个Writer中; prefix:前缀,也可以后面调用logger.SetPrefix设置; flag:选项,也可以后面调用logger.SetFlag设置。 上面代码将日志输出到一个bytes.Buffer,然后将这个buf打印到标准输出。
log_print(__LOG_INFO,NULL,"[Info]:"_LOG_TAG format"\r\n", ## __VA_ARGS__)#definelog_info_hexdump(x, y) \if(LOG_IS_ENABLE(LOG_INFO)) \ printf_buf(x, y)#definelog_debug(format, ...) \if(LOG_IS_ENABLE(LOG_DEBUG)) \ ...
printascii(printk_buf); #endif print_asciii使用汇编实现的,在文件arch/arm/kernel/debug.S中: .macro addruart_current, rx, tmp1, tmp2 addruart \tmp1, \tmp2 mrc p15, 0, \rx, c1, c0 tst \rx, #1 moveq \rx, \tmp1 movne \rx, \tmp2 ...
of each line // ⽇志⾏前缀4flag int// properties // ⽇志打印格式标志,⽤于指定每⾏⽇志的打印格式5out io.Writer// destination for output // ⽤于指定⽇志输出位置,理论上可以是任务地⽅,只要实现了io.Writer接⼝就⾏6buf[]byte// for accumulating text to write // ⽇志内容...
1.voidspdk_vlog(enumspdk_log_levellevel,constchar*file,constintline,constchar*func,constchar*format,va_listap)2.{3.if(level<=g_spdk_log_print_level){4.fprintf(stderr,"%s%s:%4d:%s: *%s*: %s",timestamp,file,line,func,spdk_level_names[level],buf);5.}6.7.if(level<=g_spdk_log_le...
beginning of each line // ⽇志⾏前缀flagint// properties // ⽇志打印格式标志,⽤于指定每⾏⽇志的打印格式outio.Writer// destination for output // ⽤于指定⽇志输出位置,理论上可以是任务地⽅,只要实现了io.Writer接⼝就⾏buf[]byte// for accumulating text to write // ⽇志...