当前位置: 首页>>代码示例>>C++>>正文


C++ LogMessage类代码示例

本文整理汇总了C++中LogMessage的典型用法代码示例。如果您正苦于以下问题:C++ LogMessage类的具体用法?C++ LogMessage怎么用?C++ LogMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了LogMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: write

void Log::write (LogMessage log_message) {
	for (int i = 0; (unsigned) i < Log::loggers.size(); i++) {
		if (Log::loggers[i]->get_level() >= log_message.get_level() ) {
			Log::loggers[i]->write(log_message);
		}
	}
}
开发者ID:kukinsula,项目名称:arcade_games,代码行数:7,代码来源:log.cpp

示例2: fatalCheckToString

 // helper for fatal CHECK
 std::string fatalCheckToString(const LogMessage& msg) {
    auto out = LogDetailsToString(msg);
    static const std::string contractExitReason = {"EXIT trigger caused by broken Contract:"};
    out.append("\n\t*******\t " + contractExitReason + " CHECK(" + msg.expression() + ")\n\t"
               + '"' + msg. message() + '"');
    return out;
 }
开发者ID:amarburg,项目名称:g3log,代码行数:8,代码来源:logmessage.cpp

示例3: log

 void LogAppenderBase::log(const LogMessage& message)
 {
     if(message.getLogLevel() >= m_logLevel)
     {
         logMessage(message);
     }
 }
开发者ID:mihaylov87,项目名称:capu,代码行数:7,代码来源:LogAppenderBase.cpp

示例4: write

void Appender::write(LogMessage& message)
{
    if (!level || level > message.level)
        return;

    message.prefix.clear();
    if (flags & APPENDER_FLAGS_PREFIX_TIMESTAMP)
        message.prefix.append(message.getTimeStr());

    if (flags & APPENDER_FLAGS_PREFIX_LOGLEVEL)
    {
        if (!message.prefix.empty())
            message.prefix.push_back(' ');

        char text[MAX_QUERY_LEN];
        snprintf(text, MAX_QUERY_LEN, "%-5s", Appender::getLogLevelString(message.level));
        message.prefix.append(text);
    }

    if (flags & APPENDER_FLAGS_PREFIX_LOGFILTERTYPE)
    {
        if (!message.prefix.empty())
            message.prefix.push_back(' ');

        message.prefix.push_back('[');
        message.prefix.append(message.type);
        message.prefix.push_back(']');
    }

    if (!message.prefix.empty())
        message.prefix.push_back(' ');

    _write(message);
}
开发者ID:BravadoToDeath,项目名称:ArkCORE-NG,代码行数:34,代码来源:Appender.cpp

示例5: handleMessage

void StandardLogHandler::handleMessage(
    const LogMessage& message,
    const LogCategory* handlerCategory) {
  if (message.getLevel() < getLevel()) {
    return;
  }
  writer_->writeMessage(formatter_->formatMessage(message, handlerCategory));
}
开发者ID:RcRonco,项目名称:folly,代码行数:8,代码来源:StandardLogHandler.cpp

示例6: add

// ajoute un message de log dans un fichier, et écriture dans la console
void LogSystem::add(LogMessage log) {

    QTextStream cout(stdout, QIODevice::WriteOnly);
    QFile fichier("fichierDeLog.txt");

    // ouverture en mode Append, pour écrire à la fin.
    fichier.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
    QTextStream flux(&fichier);

    QString tmp = log.toString().c_str();

    // écriture du log dans le fichier
    flux << tmp << "\n";

    // éciture du log sur la console
    cout << "Ecriture dans le fichier de log : " << log.toString().c_str() << endl;
    fichier.close();
}
开发者ID:slaidoum,项目名称:Calculatrice,代码行数:19,代码来源:LogSystem.cpp

示例7: messagePrefix

std::string FileLogHandler::messagePrefix(const LogMessage & message)
{
	std::string prefix = levelString(message.level());


	if (!message.context().empty())
	{
		if (!prefix.empty())
			prefix = prefix + " ";

		prefix = prefix + "[" + message.context() + "]";
	}

	if (prefix.empty())
		return prefix;

	return prefix + ": ";
}
开发者ID:Tobias1595,项目名称:libzeug,代码行数:18,代码来源:FileLogHandler.cpp

示例8: TEST

TEST(LogMessagePoolTests, GetAndRelease) {
  static const size_t INITIAL_CAPACITY=128;
  static const size_t MAX_CAPACITY= 1024;
  static const size_t MAX_RETURNED_MESSAGE_SIZE= 256;
  static const size_t INITIAL_POOL_SIZE= 4;
  static const size_t MAX_POOL_SIZE= 8;
  TestingLogMessagePool factory(INITIAL_CAPACITY, MAX_CAPACITY,
				MAX_RETURNED_MESSAGE_SIZE, INITIAL_POOL_SIZE,
				MAX_POOL_SIZE);
  std::vector<LogMessage*> messagesInPool;
  std::vector<LogMessage*> newMessagesInPool;
  LogMessage* msg;

  messagesInPool.reserve(INITIAL_POOL_SIZE);
  factory.getMessagesInPool(std::back_inserter(messagesInPool));
  EXPECT_EQ(messagesInPool.size(), INITIAL_POOL_SIZE);

  msg= factory.get();
  EXPECT_EQ(msg->capacity(), factory.initialMessageSize());
  EXPECT_EQ(msg->maxCapacity(), factory.maxMessageSize());
  EXPECT_TRUE(msg->empty());

  // Verify the message came from the pool
  EXPECT_EQ(factory.numMessagesInPool(), INITIAL_POOL_SIZE-1);
  EXPECT_TRUE(std::find(messagesInPool.begin(), messagesInPool.end(), msg) != messagesInPool.end());

  // Verify the message returned to the pool
  factory.release(msg);
  EXPECT_EQ(factory.numMessagesInPool(), INITIAL_POOL_SIZE);
  
  factory.getMessagesInPool(std::back_inserter(newMessagesInPool));
  std::sort(messagesInPool.begin(), messagesInPool.end());
  std::sort(newMessagesInPool.begin(), newMessagesInPool.end());
  if (messagesInPool != newMessagesInPool) {
    std::ostringstream details;
    details << "messagesInPool != newMessagesInPool\n  messagesInPool = [ "
	    << join(messagesInPool.begin(), messagesInPool.end(), ", ")
	    << " ]\n  newMessagesInPool = [ "
	    << join(newMessagesInPool.begin(), newMessagesInPool.end(), ", ")
	    << " ]";
    EXPECT_TRUE(false) << details.str();
  }
}
开发者ID:tomault,项目名称:pistis-logging,代码行数:43,代码来源:LogMessagePoolTests.cpp

示例9: log

void Console::log(const LogMessage& message) {
    if (message.string().empty())
        return;

    logToDebug(message);
    logToFile(message);
    if (m_textCtrl != NULL)
        logToConsole(message);
    else
        m_buffer.push_back(message);
}
开发者ID:WakaLakaLake,项目名称:TrenchBroom,代码行数:11,代码来源:Console.cpp

示例10: logToStdOut

    // Format and print the message
    // =============================================================================================
    void LoggerFactory::logToStdOut(const LogMessage& message)
    {
        std::stringstream ss(message.toString());
        std::string line;

        while (std::getline(ss, line, '\n'))
        {
            line += "\n";
            std::printf(line.c_str());
        }
    }
开发者ID:mamatias,项目名称:uaf,代码行数:13,代码来源:logger.cpp

示例11: logToConsole

void Console::logToConsole(const LogMessage& message) {
    long start = m_textCtrl->GetLastPosition();
    m_textCtrl->AppendText(message.string());
    m_textCtrl->AppendText("\n");
    long end = m_textCtrl->GetLastPosition();
    switch (message.level()) {
    case LLDebug:
        m_textCtrl->SetStyle(start, end, wxTextAttr(*wxLIGHT_GREY, *wxBLACK)); // SetDefaultStyle doesn't work on OS X / Cocoa
        break;
    case LLInfo:
        m_textCtrl->SetStyle(start, end, wxTextAttr(*wxWHITE, *wxBLACK)); // SetDefaultStyle doesn't work on OS X / Cocoa
        break;
    case LLWarn:
        m_textCtrl->SetStyle(start, end, wxTextAttr(*wxYELLOW, *wxBLACK)); // SetDefaultStyle doesn't work on OS X / Cocoa
        break;
    case LLError:
        m_textCtrl->SetStyle(start, end, wxTextAttr(*wxRED, *wxBLACK)); // SetDefaultStyle doesn't work on OS X / Cocoa
        break;
    }
}
开发者ID:WakaLakaLake,项目名称:TrenchBroom,代码行数:20,代码来源:Console.cpp

示例12: DoesMatch

bool LogFilterRegex::DoesMatch(const LogMessage &message) const {
  switch (m_filter_target) {
  case eFilterTargetActivity:
    // Empty fields never match a condition.
    if (!message.HasActivity())
      return false;
    return ::regexec(&m_regex, message.GetActivity(), 0, nullptr, 0) == 0;
  case eFilterTargetActivityChain:
    // Empty fields never match a condition.
    if (!message.HasActivity())
      return false;
    return ::regexec(&m_regex, message.GetActivityChain().c_str(), 0, nullptr,
                     0) == 0;
  case eFilterTargetCategory:
    // Empty fields never match a condition.
    if (!message.HasCategory())
      return false;
    return ::regexec(&m_regex, message.GetCategory(), 0, nullptr, 0) == 0;
  case eFilterTargetMessage: {
    const char *message_text = message.GetMessage();
    if (!message_text) {
      DNBLogThreadedIf(LOG_DARWIN_LOG,
                       "LogFilterRegex: regex "
                       "\"%s\" no match due to nullptr message.",
                       m_regex_text.c_str());
      return false;
    }

    bool match = ::regexec(&m_regex, message_text, 0, nullptr, 0) == 0;
    DNBLogThreadedIf(LOG_DARWIN_LOG, "LogFilterRegex: regex "
                                     "\"%s\" %s message \"%s\".",
                     m_regex_text.c_str(), match ? "matches" : "does not match",
                     message_text);
    return match;
  }
  case eFilterTargetSubsystem:
    // Empty fields never match a condition.
    if (!message.HasSubsystem())
      return false;
    return ::regexec(&m_regex, message.GetSubsystem(), 0, nullptr, 0) == 0;
  default:
    // We don't know this type.
    return false;
  }
}
开发者ID:llvm-project,项目名称:lldb,代码行数:45,代码来源:LogFilterRegex.cpp

示例13: log

void LogManager::log(LogMessage msg)
{
	//don't do any formatting changes or filtering to the TTY output since we
	//use the raw output to do diffs with the output of a real PS3 and some
	//programs write text in single bytes to the console
	if (msg.mType != TTY)
	{
		std::string prefix;
		switch (msg.mServerity)
		{
		case Success:
			prefix = "S ";
			break;
		case Notice:
			prefix = "! ";
			break;
		case Warning:
			prefix = "W ";
			break;
		case Error:
			prefix = "E ";
			break;
		}
		if (NamedThreadBase* thr = GetCurrentNamedThread())
		{
			prefix += "{" + thr->GetThreadName() + "} ";
		}
		msg.mText.insert(0, prefix);
		msg.mText.append(1,'\n');
	}
#ifdef BUFFERED_LOGGING
	size_t size = msg.size();
	std::vector<char> temp_buffer(size);
	msg.serialize(temp_buffer.data());
	mBuffer.pushRange(temp_buffer.begin(), temp_buffer.end());
	mBufferReady.notify_one();
#else
	mChannels[static_cast<u32>(msg.mType)].log(msg);
#endif
}
开发者ID:Arkaran99,项目名称:rpcs3,代码行数:40,代码来源:Log.cpp

示例14: _write

void AppenderFile::_write(LogMessage const& message)
{
    bool exceedMaxSize = maxFileSize > 0 && (fileSize.value() + message.Size()) > maxFileSize;

    if (dynamicName)
    {
        char namebuf[TRINITY_PATH_MAX];
        snprintf(namebuf, TRINITY_PATH_MAX, filename.c_str(), message.param1.c_str());
        logfile = OpenFile(namebuf, mode, backup || exceedMaxSize);
    }
    else if (exceedMaxSize)
        logfile = OpenFile(filename, "w", true);

    if (!logfile)
        return;

    fprintf(logfile, "%s%s", message.prefix.c_str(), message.text.c_str());
    fflush(logfile);
    fileSize += uint64(message.Size());

    if (dynamicName)
        CloseFile();
}
开发者ID:Caydan,项目名称:WoWSCore548,代码行数:23,代码来源:AppenderFile.cpp

示例15: admitMessage

void LogCategory::admitMessage(const LogMessage& message) const {
  processMessage(message);

  // If this is a fatal message, flush the handlers to make sure the log
  // message was written out, then crash.
  if (isLogLevelFatal(message.getLevel())) {
    auto numHandlers = db_->flushAllHandlers();
    if (numHandlers == 0) {
      // No log handlers were configured.
      // Print the message to stderr, to make sure we always print the reason
      // we are crashing somewhere.
      auto msg = folly::to<std::string>(
          "FATAL:",
          message.getFileName(),
          ":",
          message.getLineNumber(),
          ": ",
          message.getMessage(),
          "\n");
      folly::writeFull(STDERR_FILENO, msg.data(), msg.size());
    }
    std::abort();
  }
}
开发者ID:RcRonco,项目名称:folly,代码行数:24,代码来源:LogCategory.cpp


注:本文中的LogMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。