#include "Logger.hpp"
#include <sstream>

std::string Logger::currentStateLabel{"NoState"};
static constexpr std::string_view loggerID = "logger";

void Logger::setStateLabel(const std::string& label)
{
	currentStateLabel = label;
}

void Logger::logEngFileHeader()
{
	logEngLine(ALWAYS, loggerID, "dateTime_Z", "state", "comment");
	logEngLine(ALWAYS, loggerID, "text", "text", "text");
}

void Logger::logEngLine(LogLevels verbosity, const std::initializer_list<std::string_view> args)
{
	std::ostringstream log_string;
	log_string << STX;

	// We stop one before the end to avoid the extra delimiter
	auto end_target = args.end();
	end_target--;
	for(auto value = args.begin(); value != end_target; value++)
	{
		log_string << *value << DELIMITER;
	}

	// Then we add the end and close out the string
	log_string << *end_target << ETX;

	// Log the formatted string
	logLine(verbosity, log_string.str());
}
