void ConsoleLogSink::doPrintMessage(qbs::LoggerLevel level, const QString &message, const QString &tag) { if (!m_enabled) return; FILE * const file = level == qbs::LoggerInfo && tag != QStringLiteral("stdErr") ? stdout : stderr; const QString levelTag = logLevelTag(level); TextColor color = TextColorDefault; switch (level) { case qbs::LoggerError: color = TextColorRed; break; case qbs::LoggerWarning: color = TextColorYellow; break; default: break; } fprintfWrapper(color, file, levelTag.toLocal8Bit().constData()); static QHash<QString, TextColor> colorTable = setupColorTable(); fprintfWrapper(colorTable.value(tag, TextColorDefault), file, "%s\n", message.toLocal8Bit().constData()); fflush(file); }
void SipXecsService::setLogPriority(const OsConfigDb& configSettings, // configuration data const char* servicePrefix, /* the string "_LOG_LEVEL" is * appended to this prefix to * find the config directive that * sets the level */ OsSysLogPriority defaultLevel // default default is "NOTICE" ) { UtlString logLevel; UtlString logLevelTag(servicePrefix); logLevelTag.append(LogLevelSuffix); configSettings.get(logLevelTag, logLevel); OsSysLogPriority priority; if ( logLevel.isNull() ) { OsSysLog::add(FAC_KERNEL,PRI_WARNING, "SipXecsService::setLogPriority: %s not found, using '%s'", logLevelTag.data(), OsSysLog::priorityName(defaultLevel) ); priority = defaultLevel; } else if ( ! OsSysLog::priority(logLevel.data(), priority)) { OsSysLog::add(FAC_KERNEL,PRI_ERR, "SipXecsService::setLogPriority: %s value '%s' is invalid, using '%s'", logLevelTag.data(), logLevel.data(), OsSysLog::priorityName(defaultLevel) ); priority = defaultLevel; } OsSysLog::setLoggingPriority(priority); }