mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-28 22:03:20 +01:00
* fix: keep the shared log.txt and errors.txt when the run writes multiplelogs Every start deleted log.txt and errors.txt in the game folder before the settings were read, so a run with multiplelogs (each scenario test) wiped the logs of the player's last ordinary game although it writes its own files in logs/. The shared files are now deleted after the settings, and only without multiplelogs, where the run is about to write them (an errors.txt of an earlier run must still not stay behind a run without errors). The log service keeps what is logged until then, so an early message can't open and empty log.txt before multiplelogs is known. The file names come from one place (utilities/logfiles), covered by unit tests. * refactor(log): the wait for the log file names without Sonar issues The log service skips a pass with an early continue instead of wrapping the writing in an if, so the writing keeps its nesting. No change in behaviour. * fix(log): the node bank preview tool opens its log files after the settings The log service holds every message until OpenLogFiles() is called, and only the game called it. The preview tool kept its whole log in memory and wrote it only at the end, so a crash or a killed run lost it.
30 lines
1.2 KiB
C++
30 lines
1.2 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
// the files the log is written to, and which of them a run clears when it starts. kept apart from the log service so
|
|
// the unit tests can check them
|
|
|
|
// the log of everything, and the list of the errors (made at the first error)
|
|
enum class log_file { log, errors };
|
|
|
|
// the name of a log file: the shared one in the game folder, or with multiplelogs the run's own in logs/, named after
|
|
// the scenery and the time
|
|
std::string log_file_name(log_file Kind, bool MultipleLogs, std::string_view Scenery, std::string_view Date);
|
|
|
|
// the shared log files a run deletes when it starts: the ones it writes itself, that is without multiplelogs, so an
|
|
// errors.txt of an earlier run doesn't stay behind when this one logs no error. with multiplelogs the run writes files
|
|
// of its own in logs/, and the log.txt / errors.txt of the last ordinary run are kept
|
|
std::vector<std::string> stale_log_files(bool MultipleLogs);
|