Skip to content

Commit

Permalink
5.7.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
bha-evs committed Jul 30, 2024
1 parent 9034b82 commit 5718319
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ include(cmake/fetch_content.cmake)
# in code coverage computation as they are test programs themselves.
set(EXTRA_COVERAGE_EXCLUSION "\'${CMAKE_CURRENT_SOURCE_DIR}/integration/*\'")

project(bofstd VERSION 5.7.2.4)
project(bofstd VERSION 5.7.2.5)

if (EMSCRIPTEN)
message("Force pthread detection for BofStd compilation under EMSCRIPTEN")
Expand Down
18 changes: 9 additions & 9 deletions lib/include/bofstd/bofbasicloggerfactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
#include <string.h>

BEGIN_BOF_NAMESPACE()
class BasicLogger : public BOF::IBofLogger
class BofBasicLogger : public BOF::IBofLogger
{
public:
BasicLogger(const std::string &_rLibNamePrefix_S, const std::string &_rLoggerChannelName_S)
BofBasicLogger(const std::string &_rLibNamePrefix_S, const std::string &_rLoggerChannelName_S)
: BOF::IBofLogger()
{
mChannelName_S = _rLibNamePrefix_S + _rLoggerChannelName_S;
Open(false, false, false, 0, "");
}
virtual ~BasicLogger()
virtual ~BofBasicLogger()
{
if (mpLogFile_X)
{
Expand Down Expand Up @@ -60,7 +60,7 @@ class BasicLogger : public BOF::IBofLogger

t = std::time(nullptr);
std::strftime(pDateTime_c, sizeof(pDateTime_c), "%Y-%m-%d %H:%M:%S", std::localtime(&t));
BOF_GET_FILE_FROM_PATH(_rFile_S.c_str(), pFile_c)
BOF_GET_FILE_FROM_PATH(_rFile_S.c_str(), pFile_c);
sprintf(pHeader_c, "%s: %zd [%s] %s:%d (%s)->", pDateTime_c, DeltaInuS, mChannelName_S.c_str(), pFile_c, _Line_U32, _rFunc_S.c_str());
mNbLogLine_U32++;
if (mOutputOnScreen_B)
Expand Down Expand Up @@ -136,7 +136,7 @@ class BasicLogger : public BOF::IBofLogger
bool SwapLogFile()
{
bool Rts_B = false;
char pBackLogFilePath_c[1024];
char pBackLogFilePath_c[1024+32];

//if (Close()) //No because never ending loop (Close call V_Log) and modify var mOutputOnScreen_B
if (mpLogFile_X)
Expand Down Expand Up @@ -202,13 +202,13 @@ class BofBasicLoggerFactory : public BOF::IBofLoggerFactory
}
std::shared_ptr<BOF::IBofLogger> V_Create(const std::string &_rLibNamePrefix_S, const std::string &_rLoggerChannelName_S) override
{
std::shared_ptr<BasicLogger> psRts = nullptr;
std::shared_ptr<BofBasicLogger> psRts = nullptr;
std::string ChannelName_S;

std::lock_guard<std::mutex> Lock(mLoggerCollectionMtx);
if (V_GetLogger(_rLibNamePrefix_S, _rLoggerChannelName_S) == nullptr)
{
psRts = std::make_shared<BasicLogger>(_rLibNamePrefix_S, _rLoggerChannelName_S);
psRts = std::make_shared<BofBasicLogger>(_rLibNamePrefix_S, _rLoggerChannelName_S);
if (psRts)
{
if (psRts->Open(mOutputOnScreen_B, mAppend_B, mAutoFlush_B, mMaxSize_U32, mLogFileSubDir_S))
Expand All @@ -226,7 +226,7 @@ class BofBasicLoggerFactory : public BOF::IBofLoggerFactory
}
std::shared_ptr<BOF::IBofLogger> V_GetLogger(const std::string &_rLibNamePrefix_S, const std::string &_rLoggerChannelName_S) override
{
std::shared_ptr<BasicLogger> psRts = nullptr;
std::shared_ptr<BofBasicLogger> psRts = nullptr;
std::string ChannelName_S;
// no mutex as it is used by V_Create and V_Destroy
ChannelName_S = BuildChannelName(_rLibNamePrefix_S, _rLoggerChannelName_S);
Expand Down Expand Up @@ -254,7 +254,7 @@ class BofBasicLoggerFactory : public BOF::IBofLoggerFactory

private:
std::mutex mLoggerCollectionMtx;
std::map<std::string, std::shared_ptr<BasicLogger>> mLoggerCollection;
std::map<std::string, std::shared_ptr<BofBasicLogger>> mLoggerCollection;
bool mOutputOnScreen_B;
bool mAppend_B;
bool mAutoFlush_B;
Expand Down
19 changes: 14 additions & 5 deletions lib/include/bofstd/bofstd.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ cmake -DCMAKE_TOOLCHAIN_FILE=C:/pro/vcpkg/scripts/buildsystems/vcpkg.cmake -DBUI
#if defined(_WIN32)
#define NOMINMAX
#include <WinSock2.h>
#include <ws2tcpip.h>
#include <Windows.h>
#include <ws2tcpip.h>
typedef bool(WINAPI *BofSignalHandler)(uint32_t);
#else
#if defined(__EMSCRIPTEN__)
#include <emscripten/html5.h> //for emscripten_performance_now in Bof_RdTsc
using BofEmscriptenCallback = std::function<BOFERR(void *)>;
#else
#include <x86intrin.h> //for __rdtsc in Bof_RdTsc
#include <x86intrin.h> //for __rdtsc in Bof_RdTsc
#endif
typedef bool (*BofSignalHandler)(uint32_t);
#endif
Expand Down Expand Up @@ -350,8 +350,17 @@ const uintptr_t BOF_INVALID_HANDLE_VALUE = ((uintptr_t)-1);
{ \
pFile = strrchr(pPath, '/'); \
if (!pFile) \
{ \
pFile = strrchr(pPath, '\\'); \
pFile = pFile ? ++pFile : pPath; \
} \
if (pFile) \
{ \
pFile++; \
} \
else \
{ \
pFile = pPath; \
} \
}
#define BOF_COMPUTE_DELTA(start, end, delta) \
{ \
Expand Down Expand Up @@ -656,7 +665,7 @@ inline BOFSTD_EXPORT uint64_t Bof_RdTsc()
asm volatile ("rdtsc" : "=a" (Low_U32), "=d" (High_U32));
return (((uint64_t)High_U32 << 32) | Low_U32);
*/
return static_cast<uint64_t>(emscripten_performance_now() * 1000000.0); //Calls JavaScript performance.now(), returns a high precision wallclock time value in msecs.
return static_cast<uint64_t>(emscripten_performance_now() * 1000000.0); // Calls JavaScript performance.now(), returns a high precision wallclock time value in msecs.
#else
return __rdtsc();
#endif
Expand Down Expand Up @@ -735,7 +744,7 @@ class BOFSTD_EXPORT BofException : public std::exception
BOF::BofException Exception(Header, Context, Where.str(), ErrorCode); \
throw Exception; \
}
//extern BOFSTDPARAM GL_BofStdParam_X;
// extern BOFSTDPARAM GL_BofStdParam_X;

END_BOF_NAMESPACE()

Expand Down
2 changes: 1 addition & 1 deletion tests/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ int main(int argc, char *argv[])
//::testing::GTEST_FLAG(filter) = "RawCircularBuffer_Test.FillWrapOverwrite";
//::testing::GTEST_FLAG(filter) = "RawCircularBuffer_Test.*:CircularBuffer_Test.*:RawCircularBufferInSlotMode_Test.*";
//::testing::GTEST_FLAG(filter) = "BofThreadPool_Test.Dispatch";
::testing::GTEST_FLAG(filter) = "ut_logger_ibofloggerfactory.MultipleChannel*";
//::testing::GTEST_FLAG(filter) = "Fs_Test.**";
// ::testing::GTEST_FLAG(filter) = "RawCircularBufferAlwaysContiguous_Test.*:RawCircularBuffer_Test.*:RawCircularBufferInSlotMode_Test.*";
// std::string CrtDir_S;
// BOF::Bof_GetCurrentDirectory(CrtDir_S);
Expand Down
6 changes: 3 additions & 3 deletions tests/src/ut_fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,8 @@ TEST(Fs_Test, ResetFileContent)
NewLine_S = Line_S + Line_S;
EXPECT_STREQ(LineRead_S.c_str(), NewLine_S.c_str());

#if defined(_WIN32)
#else
//#if defined(_WIN32)
//#else
EXPECT_EQ(Bof_ResetFileContent(Path, false, Line_S.size()), BOF_ERR_NO_ERROR);

EXPECT_EQ(Bof_ReadFile(Path, LineRead_S), BOF_ERR_NO_ERROR);
Expand All @@ -772,5 +772,5 @@ TEST(Fs_Test, ResetFileContent)
EXPECT_EQ(Bof_ReadFile(Path, LineRead_S), BOF_ERR_NO_ERROR);
// EXPECT_STREQ(LineRead_S.c_str(), (Line_S + LineWrt_S).c_str());
EXPECT_STREQ(LineRead_S.c_str(), Line_S.c_str()); // Extra zero are inserted at the beginning as Io has an offset of Line_S.size() but the file has been shrinked to O byte->write add extra 0 upp to crt file pos LineWrt_S.c_str());
#endif
//#endif
}
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bofstd",
"version": "5.7.2.4",
"version": "5.7.2.5",
"description": "The onbings general purpose C++ Multiplatform library",
"dependencies": [
{
Expand Down

0 comments on commit 5718319

Please sign in to comment.