summaryrefslogtreecommitdiffstats
path: root/src/ui/widget/canvas/framecheck.cpp
blob: c127c8e805cf1b2ee33178babad2c0dfffb4ea0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// SPDX-License-Identifier: GPL-2.0-or-later
#include <fstream>
#include <iostream>
#include <mutex>
#include <boost/filesystem.hpp> // Using boost::filesystem instead of std::filesystem due to broken C++17 on MacOS.
#include "framecheck.h"
namespace fs = boost::filesystem;

namespace Inkscape::FrameCheck {

void Event::write()
{
    static std::mutex mutex;
    static auto logfile = [] {
        auto path = fs::temp_directory_path() / "framecheck.txt";
        auto mode = std::ios_base::out | std::ios_base::app | std::ios_base::binary;
        return std::ofstream(path.string(), mode);
    }();

    auto lock = std::lock_guard(mutex);
    logfile << name << ' ' << start << ' ' << g_get_monotonic_time() << ' ' << subtype << std::endl;
}

} // namespace Inkscape::FrameCheck