<commit_before>#include <stdio.h>
#include <sstream>

#include "liblogger.h"

namespace liblogger
{

LogTail::LogTail(size_t length)
{
	m_length = length;
}

void LogTail::GetName(std::string *str)
{
	*str = "Tail";
}

void LogTail::GetDesc(std::string *str)
{
	*str = "Keeps Last 'n' Messages in memory";
}

void LogTail::Log(const LogType Type, const std::string &str)
{
	if (m_data.size() >= m_length)
		m_data.pop_front();
	m_data.push_back(str);
}

std::string LogTail::GetData()
{
	std::list<std::string>::iterator it = m_data.begin();
	std::stringstream ss;
	while(it != m_data.end())
	{
		ss << *it << '\n';
		it++;
	}
	return ss.str();
}<commit_msg>Fix Race in LogTail::GetData<commit_after>#include <stdio.h>
#include <sstream>

#include "liblogger.h"

namespace liblogger
{

LogTail::LogTail(size_t length)
{
	m_length = length;
}

void LogTail::GetName(std::string *str)
{
	*str = "Tail";
}

void LogTail::GetDesc(std::string *str)
{
	*str = "Keeps Last 'n' Messages in memory";
}

void LogTail::Log(const LogType Type, const std::string &str)
{
	if (m_data.size() >= m_length)
		m_data.pop_front();
	m_data.push_back(str);
}

std::string LogTail::GetData()
{
	LogManager::Lock();
	std::list<std::string>::iterator it = m_data.begin();
	std::stringstream ss;
	while(it != m_data.end())
	{
		ss << *it << '\n';
		it++;
	}
	LogManager::Unlock();
	return ss.str();
}
{'fraction_non_alphanumeric': 0.19345454545454546, 'fraction_numerical': 0.0, 'mean_word_length': 5.198198198198198, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 11, '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': '2173274', 'n_tokens_mistral': 583, 'n_tokens_neox': 573, 'n_words': 113}