-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.cpp
More file actions
28 lines (24 loc) · 833 Bytes
/
debug.cpp
File metadata and controls
28 lines (24 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "global.h"
DebugFile::DebugFile(std::filesystem::path filename) noexcept
{
try
{
const std::filesystem::path filepath(dataDirectory / filename);
// If first use of file, clear it
static std::unordered_set<std::filesystem::path> initialised;
if (initialised.insert(filepath).second)
open(filepath, trunc);
else
open(filepath, app | ate);
const std::time_t time(std::time({}));
*this << std::put_time(std::gmtime(&time), "%c") << " - "sv;
}
catch (const std::exception&)
{
// There's nothing I can do to handle this exception; but catch it anyways, because this is a non-fatal error
}
}
void DebugFile::init(std::filesystem::path dataDirectory_in) noexcept
{
dataDirectory = std::move(dataDirectory_in);
}