-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogWriter.cpp
38 lines (34 loc) · 1.1 KB
/
LogWriter.cpp
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
29
30
31
32
33
34
35
36
37
38
#include "LogWriter.h"
#include <iostream>
#include <fstream>
LogWriter::LogWriter() {
// Конструктор
m_outputFormat = "console"; // По умолчанию
}
LogWriter::~LogWriter() {
// Деструктор
}
void LogWriter::setOutputFormat(const std::string& format) {
m_outputFormat = format;
}
void LogWriter::writeResults(const std::vector<std::string>& results) {
if (m_outputFormat == "console") {
// Вывод в консоль
for (const std::string& result : results) {
std::cout << result << std::endl;
}
} else if (m_outputFormat == "file") {
// Запись в файл (пример)
std::ofstream outputFile("analysis_results.txt");
if (outputFile.is_open()) {
for (const std::string& result : results) {
outputFile << result << std::endl;
}
outputFile.close();
} else {
std::cerr << "Error opening output file." << std::endl;
}
} else {
std::cerr << "Unsupported output format: " << m_outputFormat << std::endl;
}
}