1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #include "includes.h"
- void ologShow(char level, char fa, char * fmt, ...){
- static char info[512];
- static nwy_osiMutex_t *echo_mutex = NULL;
- va_list va;
- int len,i;
- char buf[10];
-
- if(sutApp.authReady==0) return;
-
- if(usb_log_status==false) return;
- if(NULL==echo_mutex) echo_mutex = nwy_create_mutex();
- if(NULL==echo_mutex) return;
- nwy_lock_mutex(echo_mutex, 0);
- va_start(va, fmt);
- vsnprintf(info, sizeof(info), fmt, va);
- va_end(va);
- //输出
- memset(buf,0,sizeof(buf));
- switch(level){
- case LINFO:strcpy(buf, "[AP_INFO]");break;
- case LWARN:strcpy(buf, "[AP_WARN]");break;
- case LERR:strcpy(buf, "[AP_ERR]");break;
- default:break;
- }
- len=strlen(buf);
- if(len>0) nwy_usb_serial_send(buf,len);
- len=strlen(info);
- i=0;
- while(1){
- int txsize = nwy_usb_serial_send(info+i, len-i);
- if(txsize<=0) break;
- i += txsize;
- if(i<len) nwy_sleep(10);
- else break;
- }
- if(fa) nwy_usb_serial_send("\r\n", 2);
- nwy_unlock_mutex(echo_mutex);
- }
|