/**
        The log file backend path in provider log configuration should be 
        case sensitive.
     */   
    void testProviderLogFilePathIsCaseSensitive()
    {
        SelfDeletingFilePath cfgfile(SCXFileSystem::DecodePath("log.conf"));
        cfgfile.SetDirectory(L"./testfiles/");

        SCX_LogConfigurator subject(cfgfile);

        subject.Set( L"FILE:/var/opt/microsoft/scx/log/scx.log:module", L"TRACE" );
        subject.Set( L"FILE:/VAR/Opt/Microsoft/scx/log/scx.log:module", L"ERROR" );

        CPPUNIT_ASSERT( L"TRACE" == GetLogLevel(cfgfile, L"FILE", L"/var/opt/microsoft/scx/log/scx.log", L"module") );
        CPPUNIT_ASSERT( L"ERROR" == GetLogLevel(cfgfile, L"FILE", L"/VAR/Opt/Microsoft/scx/log/scx.log", L"module") );
    }
    /**
        The severity threshold in provider log configuration should be 
        case insensitive.
     */   
    void testProviderLogSeverityIsCaseInsensitive()
    {
        SelfDeletingFilePath cfgfile(SCXFileSystem::DecodePath("log.conf"));
        cfgfile.SetDirectory(L"./testfiles/");

        SCX_LogConfigurator subject(cfgfile);

        subject.Set( L"STDOUT:module", L"trace" );
        subject.Set( L"STDOUT:MODULE", L"TrAcE" );
        subject.Set( L"STDOUT:MoDuLe", L"TRACE" );

        CPPUNIT_ASSERT( L"TRACE" == GetLogLevel(cfgfile, L"STDOUT", L"", L"module") );
        CPPUNIT_ASSERT( L"TRACE" == GetLogLevel(cfgfile, L"STDOUT", L"", L"MODULE") );
        CPPUNIT_ASSERT( L"TRACE" == GetLogLevel(cfgfile, L"STDOUT", L"", L"MoDuLe") );
    }
Beispiel #3
0
/**
 * @param eLogLevel - log level number.
 * @param eEntryMode - entry mode.
 * @param rcsConsoleAccess - provides synchronous access to the console.
 * @param pszEntry - log entry text.
 * @return true if operation was completed successfully.
 */
BOOL CLogStream::WriteLogEntry(BUGTRAP_LOGLEVEL eLogLevel, ENTRY_MODE eEntryMode, CRITICAL_SECTION& rcsConsoleAccess, PCTSTR pszEntry)
{
	_ASSERTE(m_hFile != INVALID_HANDLE_VALUE);
	if (m_hFile == INVALID_HANDLE_VALUE)
		return FALSE;
	_ASSERTE(eEntryMode == EM_APPEND);
	if (eEntryMode != EM_APPEND)
		return FALSE;
	BUGTRAP_LOGLEVEL eLogFileLevel = GetLogLevel();
	if (eLogLevel <= eLogFileLevel)
	{
		SYSTEMTIME st;
		GetLocalTime(&st);
		if (! WriteLogEntryToConsole(eLogLevel, &st, rcsConsoleAccess, pszEntry))
			FillEntryText(eLogLevel, &st, pszEntry);
		EncodeEntryText();
		const BYTE* pBuffer = m_MemStream.GetBuffer();
		if (pBuffer == NULL)
			return FALSE;
		DWORD dwLength = (DWORD)m_MemStream.GetLength();
		_ASSERTE(dwLength > 0);
		DWORD dwWritten;
		return WriteFile(m_hFile, pBuffer, dwLength, &dwWritten, NULL);
	}
	return TRUE;
}
    /**
        The log backend name (FILE or STDOUT) in provider log configuration should be 
        case insensitive.
     */   
    void testProviderLogBackendNameIsCaseInsensitive()
    {
        SelfDeletingFilePath cfgfile(SCXFileSystem::DecodePath("log.conf"));
        cfgfile.SetDirectory(L"./testfiles/");

        SCX_LogConfigurator subject(cfgfile);

        subject.Set( L"STDOUT:module", L"TRACE" );
        subject.Set( L"stdout:module", L"INFO" );

        subject.Set( L"FILE:/var/opt/microsoft/scx/log/scx.log:module", L"TRACE" );
        subject.Set( L"file:/var/opt/microsoft/scx/log/scx.log:module", L"ERROR" );

        CPPUNIT_ASSERT( L"INFO" == GetLogLevel(cfgfile, L"STDOUT", L"", L"module") );
        CPPUNIT_ASSERT( L"ERROR" == GetLogLevel(cfgfile, L"FILE", L"/var/opt/microsoft/scx/log/scx.log", L"module") );
    }
Beispiel #5
0
/**
 * @param eLogLevel - log level number.
 * @param eEntryMode - entry mode.
 * @param rcsConsoleAccess - provides synchronous access to the console.
 * @param pszEntry - log entry text.
 * @return true if operation was completed successfully.
 */
BOOL CTextLogFile::WriteLogEntry(BUGTRAP_LOGLEVEL eLogLevel, ENTRY_MODE eEntryMode, CRITICAL_SECTION& rcsConsoleAccess, PCTSTR pszEntry)
{
	BOOL bResult = TRUE;
	BUGTRAP_LOGLEVEL eLogFileLevel = GetLogLevel();
	if (eLogLevel <= eLogFileLevel)
	{
		SYSTEMTIME st;
		GetLocalTime(&st);
		if (! WriteLogEntryToConsole(eLogLevel, &st, rcsConsoleAccess, pszEntry))
			FillEntryText(eLogLevel, &st, pszEntry);
		EncodeEntryText();
		switch (eEntryMode)
		{
		case EM_APPEND:
			AddToTail(FALSE);
			break;
		case EM_INSERT:
			AddToHead(FALSE);
			break;
		default:
			_ASSERT(FALSE);
			bResult = FALSE;
		}
	}
	return bResult;
}
Beispiel #6
0
void ILogger::TryFatal(LPCTSTR format, ...)
{
	if(LL_FATAL < GetLogLevel())
		return;

	va_list arg_ptr;
	va_start(arg_ptr, format);
	LogV(LL_FATAL, format, arg_ptr);
	va_end(arg_ptr);
}
Beispiel #7
0
void ILogger::TryError(LPCTSTR format, ...)
{
	if(LL_ERROR < GetLogLevel())
		return;

	va_list arg_ptr;
	va_start(arg_ptr, format);
	LogV(LL_ERROR, format, arg_ptr);
	va_end(arg_ptr);
}
Beispiel #8
0
void ILogger::TryWarn(LPCTSTR format, ...)
{
	if(LL_WARN < GetLogLevel())
		return;

	va_list arg_ptr;
	va_start(arg_ptr, format);
	LogV(LL_WARN, format, arg_ptr);
	va_end(arg_ptr);
}
Beispiel #9
0
void ILogger::TryInfo(LPCTSTR format, ...)
{
	if(LL_INFO < GetLogLevel())
		return;

	va_list arg_ptr;
	va_start(arg_ptr, format);
	LogV(LL_INFO, format, arg_ptr);
	va_end(arg_ptr);
}
Beispiel #10
0
void ILogger::TryTrace(LPCTSTR format, ...)
{
	if(LL_TRACE < GetLogLevel())
		return;

	va_list arg_ptr;
	va_start(arg_ptr, format);
	LogV(LL_TRACE, format, arg_ptr);
	va_end(arg_ptr);
}
Beispiel #11
0
void ILogger::TryDebug(LPCTSTR format, ...)
{
	if(LL_DEBUG < GetLogLevel())
		return;

	va_list arg_ptr;
	va_start(arg_ptr, format);
	LogV(LL_DEBUG, format, arg_ptr);
	va_end(arg_ptr);
}
Beispiel #12
0
void ILogger::TryLog(LogLevel ll, LPCTSTR format, ...)
{
	if(ll < GetLogLevel())
		return;

	va_list arg_ptr;
	va_start(arg_ptr, format);
	LogV(ll, format, arg_ptr);
	va_end(arg_ptr);
}
void CRelaxReminderDlg::SaveSettingToIniFile()
{
    // 进入临界区保护
    EnterCriticalSection(&m_csSettingFile); 

    CreateIniFileHeader(m_strConfigFile);

    CIni Ini(m_strConfigFile);
    
    // 先保存版本信息
    Ini.Write("Version", "CurrentVersion", VersionNum2String(m_dwVersion));

    // 保存时间参数
    Ini.Write("Time", "WorkDuration",       m_tm.GetWD());
    Ini.Write("Time", "ShortRelaxDuration", m_tm.GetSRD());
    Ini.Write("Time", "EnableLongRelax",    m_tm.GetEnableLongRelax());
    Ini.Write("Time", "LongRelaxFrequency", m_tm.GetLRF());
    Ini.Write("Time", "LongRelaxDuration",  m_tm.GetLRD());
    
    // 保存提示参数
    Ini.Write("Notify", "PreNotify",            m_bPreNotify);
    Ini.Write("Notify", "LockInput",            m_bLockInput);
    Ini.Write("Notify", "LockType",             m_iLockType);
    Ini.Write("Notify", "GraceTimeBeforeLockInput", m_iGraceTimeBeforeLockInput);
    Ini.Write("Notify", "DarkerScreen",         m_bDarkerScreen);
    Ini.Write("Notify", "DarkerScreenAlpha",    m_iDarkerScreenAlpha);
    Ini.Write("Notify", "DarkerScreenAnimate",  m_eDarkerScreenAnimateType);
    Ini.Write("Notify", "DarkerScreenColor",    m_colorDarkerScreen);
    Ini.Write("Notify", "DarkerScreenType",     m_eDarkerScreenType);
    Ini.Write("Notify", "NotifyWindowType",     m_eNotifyWindowType);

    // 保存自动状态转换参数
    Ini.Write("AutoAway", "EnableAutoPause",    m_tm.GetEnableAutoPause());
    Ini.Write("AutoAway", "AutoPauseThreshold", m_tm.GetAPT());
    Ini.Write("AutoAway", "FullscreenPause",    m_tm.GetEnableFullScreenPause());
    Ini.Write("AutoAway", "EnableAutoReset",    m_tm.GetEnableAutoReset());
    Ini.Write("AutoAway", "AutoResetThreshold", m_tm.GetART());

    // 保存语言参数
    Ini.Write("Language", "LanguageId",         m_strLanguageId);

    // 保存杂项参数
    Ini.Write("Misc", "LockComputer",           m_bLockComputer);
    Ini.Write("Misc", "CloseMonitor",           m_bCloseMonitor);
    Ini.Write("Misc", "ShowFloatingWindow",     m_bShowFloatingWindowAtStartup);
    Ini.Write("Misc", "ShowTrayIcon",           m_bShowTrayIconAtStartup);
    Ini.Write("Misc", "EnableLog",              GetEnableLog());
    Ini.Write("Misc", "LogLevel",               GetLogLevel());
    Ini.Write("Misc", "LogFileSize",            GetLogFileSize());
    Ini.Write("Misc", "AutoStartWithSystem",    GetAppAutoStartWithSystem());

    // 离开临界区保护
    LeaveCriticalSection(&m_csSettingFile); 
}
Beispiel #14
0
void LogFilter::Init(const char* logfile)
{
	if (logfile!= NULL)
	{
		_logname = PathHelp::_base_get_name(logfile);
		_inifile = PathHelp::_base_get_file_dir(logfile);
		_inifile += "\\log.ini";
		if ((_level = GetLogLevel())<0)
			_level = DEFAULT_LEVEL;
	}
}
Beispiel #15
0
void Log::Put(Loglevel level, string message, mtime_t arrived)
{
	if (!logfile.is_open()) return;

	if (arrived == 0) arrived = BotTime::GetCurrentTimeMillis();
	string timestamp = StringUtil::FormatTime("%F %T.%nnn", arrived);
	string logline = timestamp + " " + GetLogLevel(level) + message;

	cout << logline << endl;
	logfile << logline << endl;
}
//初始化日志策略
int Frame_Logging_Strategy::InitLogStrategy(Logging_Config_Param &ConfigParam)
{
    //Set Arg List
    char cmdline[1024] = {0};

    string strTemp = ConfigParam.m_strLogLevel;
    string strLogLevel = GetLogLevel(strTemp);

    if(ConfigParam.m_bSendTerminal)
    {
        ACE_OS::sprintf(cmdline,"-s %s -f STDERR -p %s -i %d -m %d -N %d",
                        ConfigParam.m_strLogFile,
                        strLogLevel.c_str(),
                        ConfigParam.m_iChkInterval,
                        ConfigParam.m_iLogFileMaxSize,
                        ConfigParam.m_iLogFileMaxCnt);
    }
    else
    {
        ACE_OS::sprintf(cmdline,"-s %s -f OSTREAM -p %s -i %d -m %d -N %d",
                        ConfigParam.m_strLogFile,
                        strLogLevel.c_str(),
                        ConfigParam.m_iChkInterval,
                        ConfigParam.m_iLogFileMaxSize,
                        ConfigParam.m_iLogFileMaxCnt);
    }

    ACE_Reactor_Impl * pImpl = 0;

    ACE_NEW_RETURN (pImpl, ACE_TP_Reactor, -1);
    

    ACE_NEW_RETURN(pLogStraReactor, ACE_Reactor(pImpl ,1), -1);
    //ACE_NEW_RETURN(pLogStraReactor, ACE_Reactor, -1);
    ACE_NEW_RETURN(pLogStrategy, My_ACE_Logging_Strategy, -1);

    //Set Reactor
    pLogStrategy->reactor(pLogStraReactor);

    ACE_ARGV args;
    //args.add(__argv[0]);
    args.add(ACE_TEXT(cmdline));

    pLogStrategy->init(args.argc(),args.argv());

    if (ACE_Thread_Manager::instance ()->spawn(ACE_THR_FUNC (run_reactor), (void *)pLogStraReactor) == -1)
    {
        ACE_ERROR_RETURN ((LM_ERROR,"Spawning Reactor.\n"),-1);
    }

    ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) %M Init Log Strategy Success [%N,%l]\n")));
    return 0;
}
    // provider set
    void testProvSetThresholdForStdOut()
    {
        SelfDeletingFilePath cfgfile(SCXFileSystem::DecodePath("./testfiles/log.conf"));

        SCX_LogConfigurator subject(cfgfile);

        // set several entries: should create a new file with specific entries:
        subject.Set( L"STDOUT", L"TRACE" );
        subject.Set( L"STDOUT:scxtest.core.common.pal.system.common.entityenumeration", L"INFO" );

        std::string str = GetFileContent(cfgfile);

        // we should not see these entries
        CPPUNIT_ASSERT( str.find("HYSTERICAL")  == str.npos );
        CPPUNIT_ASSERT( str.find("FILE")  == str.npos );
        CPPUNIT_ASSERT( str.find("/var")  == str.npos );

        // but should see these:
        CPPUNIT_ASSERT( L"TRACE" == GetLogLevel(cfgfile, L"STDOUT", L"", L"") );
        CPPUNIT_ASSERT( L"INFO" == GetLogLevel(cfgfile, L"STDOUT", L"", L"scxtest.core.common.pal.system.common.entityenumeration") );
    }
Beispiel #18
0
void LogManager::SaveSettings()
{
  Config::SetBaseOrCurrent(LOGGER_WRITE_TO_FILE, IsListenerEnabled(LogListener::FILE_LISTENER));
  Config::SetBaseOrCurrent(LOGGER_WRITE_TO_CONSOLE,
                           IsListenerEnabled(LogListener::CONSOLE_LISTENER));
  Config::SetBaseOrCurrent(LOGGER_WRITE_TO_WINDOW,
                           IsListenerEnabled(LogListener::LOG_WINDOW_LISTENER));
  Config::SetBaseOrCurrent(LOGGER_VERBOSITY, static_cast<int>(GetLogLevel()));

  for (const auto& container : m_log)
    Config::SetBaseOrCurrent({{Config::System::Logger, "Logs", container.m_short_name}, false},
                             container.m_enable);

  Config::Save();
}
    // provider set
    void testProvSetThresholdForTwoBackends()
    {
        SelfDeletingFilePath cfgfile(SCXFileSystem::DecodePath("./testfiles/log.conf"));

        SCX_LogConfigurator subject(cfgfile);

        // Positive test to set lower case entry: should create a new file with specific entries (upper case):
        subject.Set( L"STDOUT", L"trace" );
        subject.Set( L"STDOUT:scxtest.core.common.pal.system.common.entityenumeration", L"info" );
        subject.Set( L"FILE:/myvar/opt/microsoft/scx/log/scx.log:scxtest.core.common.pal.system.common.entityenumeration", L"info" );

        std::string str = GetFileContent(cfgfile);

        // we should not see these entries
        CPPUNIT_ASSERT( str.find("HYSTERICAL")  == str.npos );
        CPPUNIT_ASSERT( str.find("/var")  == str.npos );

        // but should see these:
        CPPUNIT_ASSERT( L"TRACE" == GetLogLevel(cfgfile, L"STDOUT", L"", L"") );
        CPPUNIT_ASSERT( L"INFO" == GetLogLevel(cfgfile, L"STDOUT", L"", L"scxtest.core.common.pal.system.common.entityenumeration") );
        CPPUNIT_ASSERT( L"INFO" == GetLogLevel(cfgfile, 
                                               L"FILE", L"/myvar/opt/microsoft/scx/log/scx.log",
                                               L"scxtest.core.common.pal.system.common.entityenumeration") );
    }
Beispiel #20
0
/* static */
wxLogLevel wxLog::GetComponentLevel(wxString component)
{
    wxCRIT_SECT_LOCKER(lock, GetLevelsCS());

    const wxStringToNumHashMap& componentLevels = GetComponentLevels();
    while ( !component.empty() )
    {
        wxStringToNumHashMap::const_iterator
            it = componentLevels.find(component);
        if ( it != componentLevels.end() )
            return static_cast<wxLogLevel>(it->second);

        component = component.BeforeLast('/');
    }

    return GetLogLevel();
}
Beispiel #21
0
/* Default log handler
*/
static int usb_log_def_handler(enum USB_LOG_LEVEL level, 
								const char* app_name, 
								const char* prefix, 
								const char* func, 
								int app_prefix_func_end,
								char* message,
								int message_length)
{
#if IS_DRIVER
	DbgPrint("%s",message);
#else
	#if GetLogOuput(LOG_OUTPUT_TYPE_FILE)
		FILE* file;
		file = fopen(LOG_FILE_PATH,"a");
		if (file)
		{
			fwrite(message,1,strlen(message),file);
			fflush(file);
			fclose(file);
		}
	#endif

	#if GetLogOuput(LOG_OUTPUT_TYPE_STDERR)
		fprintf(stderr, "%s", message);
	#endif

	#if GetLogOuput(LOG_OUTPUT_TYPE_DEBUGWINDOW)
		OutputDebugStringA(message);
	#endif


	#if GetLogOuput(LOG_OUTPUT_TYPE_MSGBOX)
		if (GetLogLevel(level)==LOG_ERROR)
		{
			message[app_prefix_func_end-1]='\0';
			MessageBoxA(NULL,message+strlen(message),message,MB_OK|MB_ICONERROR);
		}
	#endif

#endif // IS_DRIVER

	return 1;
}
Beispiel #22
0
bool LogManager::IsEnabled(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level) const
{
  return m_log[type].m_enable && GetLogLevel() >= level;
}
Beispiel #23
0
/* static */
void Logger::LogVprintf(const char *function, const char *file, int line,
                        LogLevel level, va_list argList, const char *msg)
{
    if (!s_initialized)
    {
        fprintf(stderr, "ERROR: [Logger::LogVprintf] Invoked the logging system before initializing it.\n");
        __debugbreak();
    }

    // Capture this first to make the timestamp more accurately reflect the actual time of logging
    time_t timestamp = time(nullptr);

    int fullMsgLen = _vscprintf(msg, argList) + 1;  // This doesn't count the null terminator
    char *fullMsg = new char[fullMsgLen];

    _vsnprintf_s(fullMsg, fullMsgLen, fullMsgLen, msg, argList);
    va_end(argList);

    const char *logLevelStr = "INVALID_LOGLEVEL";
    switch (level)
    {
    case LOGLEVEL_ERROR:
        logLevelStr = "ERROR";
        break;

    case LOGLEVEL_WARNING:
        logLevelStr = "WARNING";
        break;

    case LOGLEVEL_MISSING:
        logLevelStr = "MISSING";
        break;

    case LOGLEVEL_ISSUE:
        logLevelStr = "ISSUE";
        break;

    case LOGLEVEL_INFO:
        logLevelStr = "INFO";
        break;

    case LOGLEVEL_VERBOSE:
        logLevelStr = "VERBOSE";
        break;

    case LOGLEVEL_DEBUG:
        logLevelStr = "DEBUG";
        break;
    }

    // NOTE: This implementation doesn't guarantee that log messages will be written in chronological
    // order, since Windows doesn't guarantee FIFO behavior when a thread relinquishes a lock. If
    // maintaining chronological order is crucial, then we can implement a priority queueing system
    // for log messages.

    EnterCriticalSection(&s_critSec);

    if (level & GetLogLevel())
    {
        // Sends error messages to stderr instead out stdout
        FILE *dest = (level <= LOGLEVEL_WARNING) ? stderr : stdout;

        if (level < LOGLEVEL_INFO)
            fprintf(dest, "%s: ", logLevelStr);

        fprintf(dest, "%s\n", fullMsg);

        if (s_logFile != INVALID_HANDLE_VALUE)
        {
#ifndef FEATURE_PAL // TODO: no localtime_s() or strftime() in PAL
            tm timeInfo;
            errno_t err = localtime_s(&timeInfo, &timestamp);
            if (err != 0)
            {
                fprintf(stderr, "WARNING: [Logger::LogVprintf] localtime failed with error %d.\n", err);
                goto CleanUp;
            }

            size_t timeStrBuffSize = 20 * sizeof(char);
            char *timeStr = (char *)malloc(timeStrBuffSize);  // Use malloc so we can realloc if necessary

            // This particular format string should always generate strings of the same size, but
            // for the sake of robustness, we shouldn't rely on that assumption.
            while (strftime(timeStr, timeStrBuffSize, "%Y-%m-%d %H:%M:%S", &timeInfo) == 0)
            {
                timeStrBuffSize *= 2;
                timeStr = (char *)realloc(timeStr, timeStrBuffSize);
            }
#else // FEATURE_PAL
            const char *timeStr = "";
#endif // FEATURE_PAL

            const char logEntryFmtStr[] = "%s - %s [%s:%d] - %s - %s\r\n";
            size_t logEntryBuffSize = sizeof(logEntryFmtStr) + strlen(timeStr) + strlen(function) +
                                      strlen(file) + 10 + strlen(logLevelStr) + strlen(fullMsg);

            char *logEntry = new char[logEntryBuffSize];
            sprintf_s(logEntry, logEntryBuffSize, logEntryFmtStr,
                      timeStr, function, file, line, logLevelStr, fullMsg);

            DWORD bytesWritten;

            if (!WriteFile(s_logFile, logEntry, (DWORD)logEntryBuffSize - 1, &bytesWritten, nullptr))
                fprintf(stderr, "WARNING: [Logger::LogVprintf] Failed to write to log file. GetLastError()=%u\n", GetLastError());

            if (!FlushFileBuffers(s_logFile))
                fprintf(stderr, "WARNING: [Logger::LogVprintf] Failed to flush log file. GetLastError()=%u\n", GetLastError());

            delete[] logEntry;

#ifndef FEATURE_PAL
            free((void*)timeStr);
#endif // !FEATURE_PAL
        }
    }

#ifndef FEATURE_PAL
CleanUp:
#endif // !FEATURE_PAL

    LeaveCriticalSection(&s_critSec);
    delete[] fullMsg;
}
Beispiel #24
0
void _usb_log_v(enum USB_LOG_LEVEL level,
                const char* app_name,
                const char* function,
                const char* format,
                va_list args)
{

    char local_buffer[LOGBUF_SIZE];
    int totalCount, count;
    const char* prefix;
    const char* func;
    char* buffer;
    int masked_level;
	int app_prefix_func_end;
#ifndef LOG_STYLE_SHORT
	const char** skip_list = NULL;
#endif

	masked_level = GetLogLevel(level);

    if (__usb_log_level < masked_level && masked_level != LOG_ERROR) return;
    buffer = local_buffer;
    totalCount = 0;
    count = 0;
    prefix = log_level_string[masked_level];
	func = function;
	app_prefix_func_end = 0;

    if (masked_level > LOG_LEVEL_MAX) masked_level = LOG_LEVEL_MAX;

    if ((level & LOG_RAW) == LOG_RAW)
    {
        count = _vsnprintf(buffer, LOGBUF_SIZE-1, format, args);
        if (count > 0)
        {
            buffer += count;
            totalCount += count;
        }
    }
    else
    {
#ifdef LOG_STYLE_SHORT
        if ((prefix) && strlen(prefix))
        {
		    count = _snprintf(buffer, (LOGBUF_SIZE-1), "%s: ",  prefix);
        }
        else
        {
		    count = 0;
        }
		func = "";
#else
		func = function;

		if (func)
		{
			// strip some prefixes to shorten function names
			skip_list=skipped_function_prefix;
			while(*skip_list && ((func)) && func[0])
			{
				func = STRIP_PREFIX(func,skip_list[0]);
				skip_list++;
			}
		}

		if(!func) func="none";

        // print app name, level string and short function name
        if ((prefix) && strlen(prefix))
        {
            count = _snprintf(buffer, (LOGBUF_SIZE-1), "%s:%s [%s] ", app_name, prefix, func);
        }
        else
        {
            count = _snprintf(buffer, (LOGBUF_SIZE-1), "%s:[%s] ", app_name, func);
        }
#endif

        if (count >= 0)
        {
			app_prefix_func_end = count;
            buffer += count;
            totalCount += count;
            count = _vsnprintf(buffer, (LOGBUF_SIZE-1) - totalCount, format, args);
            if (count > 0)
            {
                buffer += count;
                totalCount += count;
            }
        }
    }

	if (count < 0)
        totalCount = LOGBUF_SIZE - 1;

    // make sure its null terminated
    local_buffer[totalCount] = 0;

#if (!IS_DRIVER)
    if (masked_level == LOG_ERROR)
    {
        // if this is an error message then store it
        strncpy(usb_error_str, local_buffer, totalCount);
        usb_error_str[totalCount] = '\0';
        usb_error_type = USB_ERROR_TYPE_STRING;
    }
#endif

	if (user_log_hander)
	{
		if (user_log_hander(level, app_name, prefix, func, app_prefix_func_end, local_buffer, totalCount))
			return;
	}
	if (__usb_log_level >= masked_level)
	{
		usb_log_def_handler(level, app_name, prefix, func, app_prefix_func_end, local_buffer, totalCount);
	}
}