mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-04 21:16:59 +01:00
refactor(sonar): format UUIDs and log timestamps with std::format (cpp:S6494, cpp:S5945)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,8 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "utilities/Logs.h"
|
#include "utilities/Logs.h"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
#include "utilities/Globals.h"
|
#include "utilities/Globals.h"
|
||||||
#include "winheaders.h"
|
#include "winheaders.h"
|
||||||
#include "utilities/utilities.h"
|
#include "utilities/utilities.h"
|
||||||
@@ -19,7 +21,6 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
std::ofstream output; // standardowy "log.txt", można go wyłączyć
|
std::ofstream output; // standardowy "log.txt", można go wyłączyć
|
||||||
std::ofstream errors; // lista błędów "errors.txt", zawsze działa
|
std::ofstream errors; // lista błędów "errors.txt", zawsze działa
|
||||||
std::ofstream comms; // lista komunikatow "comms.txt", można go wyłączyć
|
std::ofstream comms; // lista komunikatow "comms.txt", można go wyłączyć
|
||||||
char logbuffer[ 256 ];
|
|
||||||
|
|
||||||
char const endstring[10] = "\n";
|
char const endstring[10] = "\n";
|
||||||
|
|
||||||
@@ -45,18 +46,14 @@ std::string filename_date() {
|
|||||||
::GetLocalTime( &st );
|
::GetLocalTime( &st );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::snprintf(
|
return std::format(
|
||||||
logbuffer,
|
"{}{:02}{:02}_{:02}{:02}{:03}",
|
||||||
sizeof(logbuffer),
|
|
||||||
"%d%02d%02d_%02d%02d%03d",
|
|
||||||
st.wYear,
|
st.wYear,
|
||||||
st.wMonth,
|
st.wMonth,
|
||||||
st.wDay,
|
st.wDay,
|
||||||
st.wHour,
|
st.wHour,
|
||||||
st.wMinute,
|
st.wMinute,
|
||||||
st.wMilliseconds);
|
st.wMilliseconds);
|
||||||
|
|
||||||
return std::string( logbuffer );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string filename_scenery() {
|
std::string filename_scenery() {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ Copyright (C) 2007-2014 Maciej Cierniak
|
|||||||
//#include <sys/stat.h>
|
//#include <sys/stat.h>
|
||||||
#include <charconv>
|
#include <charconv>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
#include <format>
|
||||||
//#ifndef WIN32
|
//#ifndef WIN32
|
||||||
//#include <unistd.h>
|
//#include <unistd.h>
|
||||||
//#endif
|
//#endif
|
||||||
@@ -188,16 +189,12 @@ std::string generate_uuid_v4()
|
|||||||
bytes[6] = bytes[6] & 0x0F | 0x40;
|
bytes[6] = bytes[6] & 0x0F | 0x40;
|
||||||
bytes[8] = bytes[8] & 0x3F | 0x80;
|
bytes[8] = bytes[8] & 0x3F | 0x80;
|
||||||
|
|
||||||
char buf[37]; // 36 znaków + \0
|
return std::format("{:02x}{:02x}{:02x}{:02x}-"
|
||||||
std::snprintf(buf, sizeof(buf),
|
"{:02x}{:02x}-"
|
||||||
"%02x%02x%02x%02x-"
|
"{:02x}{:02x}-"
|
||||||
"%02x%02x-"
|
"{:02x}{:02x}-"
|
||||||
"%02x%02x-"
|
"{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}",
|
||||||
"%02x%02x-"
|
bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], bytes[8], bytes[9], bytes[10], bytes[11], bytes[12], bytes[13], bytes[14], bytes[15]);
|
||||||
"%02x%02x%02x%02x%02x%02x",
|
|
||||||
bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], bytes[8], bytes[9], bytes[10], bytes[11], bytes[12], bytes[13], bytes[14], bytes[15]);
|
|
||||||
|
|
||||||
return std::string(buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double LocalRandom(double a, double b)
|
double LocalRandom(double a, double b)
|
||||||
|
|||||||
Reference in New Issue
Block a user