<commit_before>#include "mega.h"
#include "gtest/gtest.h"
#include "test.h"
#include <stdio.h>
#include <fstream>

bool gRunningInCI = false;
bool gTestingInvalidArgs = false;

using namespace mega;
using namespace std;

namespace {

class MegaLogger : public ::mega::Logger
{
public:
    void log(const char* time, int loglevel, const char* source, const char* message)
    {
        std::ostringstream os;

        os << "[";
        if (time)
        {
            os << time;
        }
        else
        {
            auto t = std::time(NULL);
            char ts[50];
            if (!std::strftime(ts, sizeof(ts), "%H:%M:%S", std::gmtime(&t)))
            {
                ts[0] = '\0';
            }
            os << ts;
        }
        os << "] " << SimpleLogger::toStr(static_cast<LogLevel>(loglevel)) << ": " << message;

        if (source)
        {
            os << " (" << source << ")";
        }
        os << std::endl;

        if (loglevel <= SimpleLogger::logCurrentLevel)
        {
            if (gRunningInCI)
            {
                if (!mLogFile.is_open())
                {
                    mLogFile.open("test_integration.log");
                }
                mLogFile << os.str();
            }
            else
            {
#ifdef _WIN32
                OutputDebugStringA(os.str().c_str());
#else
                std::cout << os.str();
#endif
                if (!gTestingInvalidArgs)
                {
                    ASSERT_NE(loglevel, logError) << os.str();
                }
            }
        }
    }

private:
    std::ofstream mLogFile;
};
<commit_msg>Enable monitoring of auto test logs from visual studio with --CI flag on<commit_after>#include "mega.h"
#include "gtest/gtest.h"
#include "test.h"
#include <stdio.h>
#include <fstream>

bool gRunningInCI = false;
bool gTestingInvalidArgs = false;

using namespace mega;
using namespace std;

namespace {

class MegaLogger : public ::mega::Logger
{
public:
    void log(const char* time, int loglevel, const char* source, const char* message)
    {
        std::ostringstream os;

        os << "[";
        if (time)
        {
            os << time;
        }
        else
        {
            auto t = std::time(NULL);
            char ts[50];
            if (!std::strftime(ts, sizeof(ts), "%H:%M:%S", std::gmtime(&t)))
            {
                ts[0] = '\0';
            }
            os << ts;
        }
        os << "] " << SimpleLogger::toStr(static_cast<LogLevel>(loglevel)) << ": " << message;

        if (source)
        {
            os << " (" << source << ")";
        }
        os << std::endl;

        if (loglevel <= SimpleLogger::logCurrentLevel)
        {
            if (gRunningInCI)
            {
                if (!mLogFile.is_open())
                {
                    mLogFile.open("test_integration.log");
                }
                mLogFile << os.str();
            }
            else
            {
#ifndef _WIN32
                std::cout << os.str();
#endif
                if (!gTestingInvalidArgs)
                {
                    ASSERT_NE(loglevel, logError) << os.str();
                }
            }
#ifdef _WIN32
            OutputDebugStringA(os.str().c_str());
#endif
        }
    }

private:
    std::ofstream mLogFile;
};

{'fraction_non_alphanumeric': 0.1400060477774418, 'fraction_numerical': 0.0042334442092530995, 'mean_word_length': 1.402323892519971, 'pattern_counts': {'":': 2, '<': 67, '<?xml version=': 0, '>': 9, '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': '1523340', 'n_tokens_mistral': 1018, 'n_tokens_neox': 967, 'n_words': 208}