Ran clang-format across all files
This commit is contained in:
1 parent
a27321df2e
commit
8f21a77150
1123 files changed
+159414
-162346
No files matched your search
@@ -1,15 +1,15 @@
|
||||
#include "ErrorReportService.h"
|
||||
|
||||
#include "lib/utils/bts_assert.h"
|
||||
#include "lib/config/config.h"
|
||||
#include "lib/config/protos/system.pb.h"
|
||||
#include "lib/utils/datetime.h"
|
||||
#include "lib/logging/logging.h"
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include "lib/utils/bts_assert.h"
|
||||
#include "lib/utils/datetime.h"
|
||||
#include <boost/date_time/gregorian/gregorian.hpp>
|
||||
#include <string>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
namespace bts {
|
||||
namespace support {
|
||||
@@ -18,8 +18,8 @@ std::string get_report_dir() {
|
||||
return config::get<config::System>().data_path() + "error_reports/";
|
||||
}
|
||||
|
||||
ErrorReportServer::ErrorReportServer(bts::api::ServiceContext& context) :
|
||||
ErrorReportServiceBase(context) {
|
||||
ErrorReportServer::ErrorReportServer(bts::api::ServiceContext &context)
|
||||
: ErrorReportServiceBase(context) {
|
||||
// create directory
|
||||
auto report_dir = get_report_dir();
|
||||
if (!boost::filesystem::exists(report_dir)) {
|
||||
@@ -29,7 +29,7 @@ ErrorReportServer::ErrorReportServer(bts::api::ServiceContext& context) :
|
||||
|
||||
ErrorReportServer::~ErrorReportServer() {}
|
||||
|
||||
void write_file(const std::string& destination, const std::string& data) {
|
||||
void write_file(const std::string &destination, const std::string &data) {
|
||||
if (data.size() > 0) {
|
||||
std::ofstream file;
|
||||
file.open(destination, std::ios::binary);
|
||||
@@ -41,46 +41,47 @@ void write_file(const std::string& destination, const std::string& data) {
|
||||
}
|
||||
|
||||
void ErrorReportServer::send_report(
|
||||
const ErrorReport& request,
|
||||
const api::Response<ErrorResponse>& reply) {
|
||||
const ErrorReport &request, const api::Response<ErrorResponse> &reply) {
|
||||
|
||||
// generate unique id using date
|
||||
auto dt = datetime::local_now();
|
||||
auto dir_name = request.user() + "-" + datetime::FIX_timestamp(dt);
|
||||
dir_name = os::sanitize_file_name(dir_name);
|
||||
dir_name = get_report_dir() + dir_name + "/";
|
||||
// generate unique id using date
|
||||
auto dt = datetime::local_now();
|
||||
auto dir_name = request.user() + "-" + datetime::FIX_timestamp(dt);
|
||||
dir_name = os::sanitize_file_name(dir_name);
|
||||
dir_name = get_report_dir() + dir_name + "/";
|
||||
|
||||
// create directory with that name
|
||||
boost::filesystem::create_directories(dir_name);
|
||||
// create directory with that name
|
||||
boost::filesystem::create_directories(dir_name);
|
||||
|
||||
// Write data to files in that directory
|
||||
// Write data to files in that directory
|
||||
|
||||
// user_text.txt
|
||||
std::ofstream file;
|
||||
file.open(dir_name + "user_text.txt");
|
||||
if (file.is_open()) {
|
||||
file << request.user() << " - " << request.contact() << std::endl;
|
||||
file << "================" << std::endl;
|
||||
file << "Error Description: " << request.error_message() << std::endl;
|
||||
file << "================" << std::endl;
|
||||
file << "User Description: " << request.user_description() << std::endl;
|
||||
file.close();
|
||||
}
|
||||
// logs.txt
|
||||
write_file(dir_name + "logs.txt", request.log());
|
||||
// screenshot.jpeg
|
||||
write_file(dir_name + "screenshot.jpeg", request.image());
|
||||
for (const auto& fd : request.files()) {
|
||||
// boost::filesystem::path p = fd.name();
|
||||
auto name = os::sanitize_file_name(fd.name());
|
||||
write_file(dir_name + name, fd.contents());
|
||||
}
|
||||
// user_text.txt
|
||||
std::ofstream file;
|
||||
file.open(dir_name + "user_text.txt");
|
||||
if (file.is_open()) {
|
||||
file << request.user() << " - " << request.contact() << std::endl;
|
||||
file << "================" << std::endl;
|
||||
file << "Error Description: " << request.error_message() << std::endl;
|
||||
file << "================" << std::endl;
|
||||
file << "User Description: " << request.user_description() << std::endl;
|
||||
file.close();
|
||||
}
|
||||
// logs.txt
|
||||
write_file(dir_name + "logs.txt", request.log());
|
||||
// screenshot.jpeg
|
||||
write_file(dir_name + "screenshot.jpeg", request.image());
|
||||
for (const auto &fd : request.files()) {
|
||||
// boost::filesystem::path p = fd.name();
|
||||
auto name = os::sanitize_file_name(fd.name());
|
||||
write_file(dir_name + name, fd.contents());
|
||||
}
|
||||
|
||||
// log error for visibility
|
||||
LOG(Gen, Error, "Support request from {} - {} {}", request.user(), request.contact(), request.user_description());
|
||||
// log error for visibility
|
||||
LOG(Gen, Error, "Support request from {} - {} {}", request.user(),
|
||||
request.contact(), request.user_description());
|
||||
|
||||
ErrorResponse r;
|
||||
reply(r);
|
||||
ErrorResponse r;
|
||||
reply(r);
|
||||
}
|
||||
|
||||
}}
|
||||
} // namespace support
|
||||
} // namespace bts
|
||||
Reference in new issue
Block a user