#include "sr_log.h"

#ifdef SR_USE_LOG


#include <stdarg.h>


#define BSP_LOG_BUF    256

extern uint8_t g_logLevel;

int _BspLogPrintf(uint8_t level,char *fmt, ...)
{

    char buf[BSP_LOG_BUF] = {0};
	int len = 0;
    va_list va_args;
	
    if (level <= SR_LogGetLevel()) 
	{  
	    // Start the va_args processing.
	    va_start(va_args, fmt);

	    len = vsnprintf((char *)buf, sizeof(buf), fmt, va_args);

		 if (len < 0 || len >= sizeof(buf)) 
		 {   
	        len = -1;  
	     } 
		 else 
		 {  
			BSP_PRINTF("%s",buf);
	     }  

	    // End the va_args processing.
	    va_end(va_args);
        
    } 

    return len;
 
}

#endif


