<commit_before>/** @file debug_log.hpp
 *
 * @brief Debug logging facilities
 *
 * @author <NAME>
 * @date 01 September 2013
 *
 * Copyright (c) 2013, <NAME>. All rights reserved.
 *
 * @todo Documentation and testing.
 */

#include <iostream>

namespace jewel
{

class Log
{
public:
	enum Level
	{
		trace,
		info,
		debug,
		warning,
		error,
		fatal
	};
	
	static Level threshold()
	{
		return threshold_aux();
	}
	
	static void set_threshold(Level p_level)
	{
		threshold_aux() = p_level;
		return;
	}

	static void flush()
	{
		std::clog.flush();
		return;
	}

private:

	static Level& threshold_aux()
	{
		static Level ret = debug;
		return ret;
	}
};




#ifdef DEBUG

	#define JEWEL_TEST_FATAL(level) \
			if (level >= Log::fatal) \
			{ \
				std::clog << "OBITUARY:\t"\
				          << "Application terminated due to Log::fatal." \
				          << std::endl; \
				std::terminate(); \
			}

	#define JEWEL_LOG(level, msg) \
		if (level >= Log::threshold()) \
		{ \
			std::clog << "SEVERITY:\t" << level \
					  << "\tMESSAGE:\t" msg \
					  << "\n"; \
			JEWEL_TEST_FATAL(level); \
		}

	#define JEWEL_LOG_LOCATION(level) \
		if (level >= Log::threshold()) \
		{ \
			std::clog << "SEVERITY:\t" << level \
			          << "\tFUNCTION:\t" << __func__ \
			          << "\tFILE:\t" << __FILE__ \
					  << "\tLINE:\t" << __LINE__ \
					  << "\n"; \
			JEWEL_TEST_FATAL(level); \
		} 
	
	#define JEWEL_LOG_VALUE(level, val) \
		if (level >= Log::threshold()) \
		{ \
			std::clog << "SEVERITY:\t" \
			          << "\tEXPRESSION:\t" << #val \
					  << "\tVALUE:\t" << x \
					  << "\n"; \
			JEWEL_TEST_FATAL(level); \
		}

#else

	#define JEWEL_TEST_FATAL(level) 0
	#define JEWEL_LOG(level, msg) 0
	#define JEWEL_LOG_LOCATION(level) 0
	#define JEWEL_LOG_VALUE(level, val) 0

#endif


}  // namespace jewel


<commit_msg>Put header guard in "debug_log.hpp", which I had inadvertently removed in recent reworking.<commit_after>/** @file debug_log.hpp
 *
 * @brief Debug logging facilities
 *
 * @author <NAME>
 * @date 01 September 2013
 *
 * Copyright (c) 2013, <NAME>. All rights reserved.
 *
 * @todo Documentation and testing.
 */

#ifndef GUARD_debug_log_hpp
#define GUARD_debug_log_hpp

#include <iostream>

namespace jewel
{

class Log
{
public:
	enum Level
	{
		trace,
		info,
		debug,
		warning,
		error,
		fatal
	};
	
	static Level threshold()
	{
		return threshold_aux();
	}
	
	static void set_threshold(Level p_level)
	{
		threshold_aux() = p_level;
		return;
	}

	static void flush()
	{
		std::clog.flush();
		return;
	}

private:

	static Level& threshold_aux()
	{
		static Level ret = debug;
		return ret;
	}
};




#ifdef DEBUG

	#define JEWEL_TEST_FATAL(level) \
			if (level >= Log::fatal) \
			{ \
				std::clog << "OBITUARY:\t"\
				          << "Application terminated due to Log::fatal." \
				          << std::endl; \
				std::terminate(); \
			}

	#define JEWEL_LOG(level, msg) \
		if (level >= Log::threshold()) \
		{ \
			std::clog << "SEVERITY:\t" << level \
					  << "\tMESSAGE:\t" msg \
					  << "\n"; \
			JEWEL_TEST_FATAL(level); \
		}

	#define JEWEL_LOG_LOCATION(level) \
		if (level >= Log::threshold()) \
		{ \
			std::clog << "SEVERITY:\t" << level \
			          << "\tFUNCTION:\t" << __func__ \
			          << "\tFILE:\t" << __FILE__ \
					  << "\tLINE:\t" << __LINE__ \
					  << "\n"; \
			JEWEL_TEST_FATAL(level); \
		} 
	
	#define JEWEL_LOG_VALUE(level, val) \
		if (level >= Log::threshold()) \
		{ \
			std::clog << "SEVERITY:\t" \
			          << "\tEXPRESSION:\t" << #val \
					  << "\tVALUE:\t" << x \
					  << "\n"; \
			JEWEL_TEST_FATAL(level); \
		}

#else

	#define JEWEL_TEST_FATAL(level) 0
	#define JEWEL_LOG(level, msg) 0
	#define JEWEL_LOG_LOCATION(level) 0
	#define JEWEL_LOG_VALUE(level, val) 0

#endif


}  // namespace jewel


#endif  // GUARD_debug_log_hpp
{'fraction_non_alphanumeric': 0.16992442011988532, 'fraction_numerical': 0.007297367735209799, 'mean_word_length': 2.4545454545454546, 'pattern_counts': {'":': 0, '<': 97, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1246854', 'n_tokens_mistral': 1747, 'n_tokens_neox': 1462, 'n_words': 304}