include/utilities/log.h
author Dmitriy Morozov <dmitriy@mrzv.org>
Thu, 18 Dec 2008 16:43:42 -0800
branchdev
changeset 97 0a9bd3f34419
parent 62 0e7554fd0d51
child 277 b4fd8880a09a
permissions -rw-r--r--
Intermediate commit while converting to the new architecture * Converted Filtration into StaticPersistence and DynamicPersistenceTrails (both right now work with the underlying std::vector rather than std::list order) * Filtration is now just an auxilliary glue (a map between Complex and Persistence) * Whether chains are vectors or lists can be interchanged * Added PersistenceDiagram with a simple bottleneck_distance() function * Converted triangle, alphashapes3d, and cech-complex examples * Lots of organizational changes (factoring utilities out into containers.h, indirect.h, property-maps.h) * Trying to document along the way with NaturalDocs-type comments

#ifndef __LOG_H__
#define __LOG_H__

#if LOGGING

#define RLOG_COMPONENT dionysus

#include <rlog/rlog.h>
#include <rlog/RLogChannel.h>
#include <rlog/StdioNode.h>
#include <sstream>

template<class T>
std::string tostring(const T& t) { std::ostringstream out; out << t; return out.str(); }
template<class T>
std::string intostring(const T& t) { std::ostringstream out; t.operator<<(out); return out.str(); }

#define AssertMsg(cond, message, ...)		do { if (!(cond)) { rError(message, ##__VA_ARGS__); rAssertSilent(cond); } } while (0)
	
#else // LOGGING

#include <unistd.h>		// for STDOUT_FILENO and STDERR_FILENO

#define rDebug(...)
#define rInfo(...)
#define rWarning(...)
#define rError(...)
#define rLog(...)

#define rAssert(...)
#define rAssertSilent(...)

#define DEF_CHANNEL(...) 0
#define RLOG_CHANNEL(...) 0

#define AssertMsg(cond, ...)

// To avoid undefined errors for RLogChannel, we create a dummy namespace
namespace rlog
{
	typedef		void			RLogChannel;

	class StdioNode
	{
		public:
								StdioNode(int,int)					{}
			void				subscribeTo(RLogChannel*)			{}

			static const int 	OutputColor = 0;
			static const int	OutputChannel = 0;
	};
}

#endif // LOGGING

static rlog::StdioNode stdoutLog(STDOUT_FILENO,
								 rlog::StdioNode::OutputColor + 
								 rlog::StdioNode::OutputChannel);

static rlog::StdioNode stderrLog(STDERR_FILENO,
								 rlog::StdioNode::OutputColor + 
								 rlog::StdioNode::OutputChannel);


#endif //__LOG_H__