Exemplo n.º 1
0
	void OnLog(const std::string &target, const std::string &module, const std::string &source, const std::string &action, const std::string &data)
	{
		for (unsigned j = this->configurations.size(); j > 0; --j)
		{
			FlatfileConfiguration *c = this->configurations[j - 1];

			if (c->name == target)
			{
				this->Clean();

				std::string message = ctime(&Sinkhole::curtime);
				Sinkhole::strip(message);

				message += " [" + module + "] " + source + ": " + action + " " + data; 
				WriteRequest *req = new WriteRequest(c, message);
				try
				{
					req->Dispatch();
					c->requests.push_back(req);
				}
				catch (const Sinkhole::Exception &ex)
				{
					Sinkhole::Log(Sinkhole::LOG_ERROR) << "Error queing log message: " << ex.GetReason();
				}
				break;
			}
		}
	}