g3log-crush.cpp 837 Bytes
Newer Older
gabime's avatar
gabime committed
1 2 3 4 5 6 7
#include <iostream>

#include <g3log/g3log.hpp>
#include <g3log/logworker.hpp>

void CrusherLoop()
{
gabime's avatar
gabime committed
8
    size_t counter = 0;
gabime's avatar
gabime committed
9 10
    while (true)
    {
gabime's avatar
gabime committed
11
        LOGF(INFO, "Some text to crush you machine. thread:");
gabime's avatar
gabime committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
        if(++counter % 1000000 == 0)
        {
            std::cout << "Wrote " << counter << " entries" << std::endl;
        }
    }
}


int main(int argc, char** argv)
{
    std::cout << "WARNING: This test will exaust all your machine memory and will crush it!" << std::endl;
    std::cout << "Are you sure you want to continue ? " << std::endl;
    char c;
    std::cin >> c;
    if (toupper( c ) != 'Y')
gabime's avatar
gabime committed
27 28 29
        return 0;

    auto worker = g3::LogWorker::createLogWorker();
gabime's avatar
gabime committed
30
    auto handle= worker->addDefaultLogger(argv[0], "g3log.txt");
gabime's avatar
gabime committed
31 32 33
    g3::initializeLogging(worker.get());
    CrusherLoop();

gabime's avatar
gabime committed
34 35 36 37
    return 0;
}