Archived

This topic is now archived and is closed to further replies.

Austrian Coder

Problem with loging function

Recommended Posts

Hello! In my login class i have this function:
	// ==================================

	void CLog::Message(std::string Message, ...)
	{
		Guard(CLog::Message);

		// Compile string to output

		va_list argList;
		va_start(argList, Message);

		m_LogStream << Message << argList << std::endl;

		va_end(argList);

		if (m_ForeFlush) m_LogStream.flush();

		Unguard();
	}
Now i want to do something like this: gLog->Message("Soundcard has %d hardware channels", m_HardwareChannels); And it returns this: Soundcard has %d hardware channels Hmm... where could be the error? Thanks, Christian

Share this post


Link to post
Share on other sites
Streams don''t expand the % specifiers. The idea is you use << to remove the need for them. If you want to use the C style then use vfprintf (or similar).

Share this post


Link to post
Share on other sites
Hmmm...

I am now using my String class (bases on std::string) and has the << operator.

gLog->Message(String("Soundcard has ") << m_HardwareChannels <<" hardware channels");

Is there a better way?

Something like

gLog->Message("Soundcard has " << m_HardwareChannels <<" hardware channels");

would be very cool.

Thanks, Christian

Share this post


Link to post
Share on other sites