Skip to content

Commit

Permalink
Fix for Win 10
Browse files Browse the repository at this point in the history
  • Loading branch information
ypujante committed Feb 1, 2022
1 parent 9e70c24 commit 8990d74
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 25 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ In addition to all the built-in loguru features, this projects adds:
Release notes
-------------

#### 1.0.1 - 2022/02/01

- Fix for Windows 10 build

#### 1.0.0 - 2022/01/24

- First release.
Expand Down
60 changes: 35 additions & 25 deletions src/cpp/logging/loguru.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1947,31 +1947,43 @@ namespace loguru
}
}

struct static_string_preamble_handler_t : public preamble_handler_t
} // namespace loguru

#endif // _WIN32

//------------------------------------------------------------------------
// Additions for rack extension
//------------------------------------------------------------------------
namespace loguru {

//------------------------------------------------------------------------
// static_string_preamble_handler_t
//------------------------------------------------------------------------
struct static_string_preamble_handler_t : public preamble_handler_t
{
static_string_preamble_handler_t(char const *iHeader, char const *iEntry) :
fHeader{iHeader ? iHeader : ""}, fEntry{iEntry ? iEntry : ""} {}

size_t header(char *buffer, size_t buffer_size) override
{
static_string_preamble_handler_t(char const *iHeader, char const *iEntry) :
fHeader{iHeader ? iHeader : ""}, fEntry{iEntry ? iEntry : ""} {}

size_t header(char *buffer, size_t buffer_size) override
{
if(fHeader.empty())
return 0;
else
return snprintf(buffer, buffer_size, "%-*s", static_cast<int>(std::max(fHeader.size(), fEntry.size())), fHeader.c_str());
}
if(fHeader.empty())
return 0;
else
return snprintf(buffer, buffer_size, "%-*s", static_cast<int>(std::max(fHeader.size(), fEntry.size())), fHeader.c_str());
}

size_t entry(char *buffer, size_t buffer_size) override
{
if(fEntry.empty())
return 0;
else
return snprintf(buffer, buffer_size, "%s", fEntry.c_str());
}
size_t entry(char *buffer, size_t buffer_size) override
{
if(fEntry.empty())
return 0;
else
return snprintf(buffer, buffer_size, "%s", fEntry.c_str());
}

private:
std::string fHeader;
std::string fEntry;
};
private:
std::string fHeader;
std::string fEntry;
};

//------------------------------------------------------------------------
// init_for_test
Expand Down Expand Up @@ -2000,9 +2012,7 @@ void init_for_re(char const *iREName)
}
}

} // namespace loguru

#endif // _WIN32
}

#ifdef _WIN32
#ifdef _MSC_VER
Expand Down

0 comments on commit 8990d74

Please sign in to comment.