mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
easylogging++: allow clipping a common filename prefix
This commit is contained in:
parent
43abf6ff45
commit
6fe39d9017
1 changed files with 20 additions and 3 deletions
23
external/easylogging++/easylogging++.h
vendored
23
external/easylogging++/easylogging++.h
vendored
|
@ -1255,8 +1255,12 @@ namespace el {
|
||||||
return fullPath.substr(0, lastSlashAt + 1);
|
return fullPath.substr(0, lastSlashAt + 1);
|
||||||
}
|
}
|
||||||
/// @brief builds stripped filename and puts it in buff
|
/// @brief builds stripped filename and puts it in buff
|
||||||
static void buildStrippedFilename(const char* filename, char buff[],
|
static void buildStrippedFilename(const char* filename, char buff[], const std::string &commonPrefix = NULL,
|
||||||
std::size_t limit = base::consts::kSourceFilenameMaxLength) {
|
std::size_t limit = base::consts::kSourceFilenameMaxLength) {
|
||||||
|
if (!commonPrefix.empty()) {
|
||||||
|
if (!strncmp(filename, commonPrefix.c_str(), commonPrefix.size()))
|
||||||
|
filename += commonPrefix.size();
|
||||||
|
}
|
||||||
std::size_t sizeOfFilename = strlen(filename);
|
std::size_t sizeOfFilename = strlen(filename);
|
||||||
if (sizeOfFilename >= limit) {
|
if (sizeOfFilename >= limit) {
|
||||||
filename += (sizeOfFilename - limit);
|
filename += (sizeOfFilename - limit);
|
||||||
|
@ -3984,12 +3988,21 @@ inline void FUNCTION_NAME(const T&);
|
||||||
return name;
|
return name;
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setFilenameCommonPrefix(const std::string &prefix) {
|
||||||
|
m_filenameCommonPrefix = prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string getFilenameCommonPrefix() {
|
||||||
|
return m_filenameCommonPrefix;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
base::type::VerboseLevel m_level;
|
base::type::VerboseLevel m_level;
|
||||||
base::type::EnumType* m_pFlags;
|
base::type::EnumType* m_pFlags;
|
||||||
std::map<std::string, base::type::VerboseLevel> m_modules;
|
std::map<std::string, base::type::VerboseLevel> m_modules;
|
||||||
std::deque<std::pair<std::string, Level>> m_categories;
|
std::deque<std::pair<std::string, Level>> m_categories;
|
||||||
std::map<std::string, std::string> m_threadNames;
|
std::map<std::string, std::string> m_threadNames;
|
||||||
|
std::string m_filenameCommonPrefix;
|
||||||
};
|
};
|
||||||
} // namespace base
|
} // namespace base
|
||||||
class LogMessage {
|
class LogMessage {
|
||||||
|
@ -4561,7 +4574,7 @@ inline void FUNCTION_NAME(const T&);
|
||||||
if (logFormat->hasFlag(base::FormatFlags::File)) {
|
if (logFormat->hasFlag(base::FormatFlags::File)) {
|
||||||
// File
|
// File
|
||||||
base::utils::Str::clearBuff(buff, base::consts::kSourceFilenameMaxLength);
|
base::utils::Str::clearBuff(buff, base::consts::kSourceFilenameMaxLength);
|
||||||
base::utils::File::buildStrippedFilename(logMessage->file().c_str(), buff);
|
base::utils::File::buildStrippedFilename(logMessage->file().c_str(), buff, ELPP->vRegistry()->getFilenameCommonPrefix());
|
||||||
base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kLogFileFormatSpecifier, std::string(buff));
|
base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kLogFileFormatSpecifier, std::string(buff));
|
||||||
}
|
}
|
||||||
if (logFormat->hasFlag(base::FormatFlags::FileBase)) {
|
if (logFormat->hasFlag(base::FormatFlags::FileBase)) {
|
||||||
|
@ -4579,7 +4592,7 @@ inline void FUNCTION_NAME(const T&);
|
||||||
if (logFormat->hasFlag(base::FormatFlags::Location)) {
|
if (logFormat->hasFlag(base::FormatFlags::Location)) {
|
||||||
// Location
|
// Location
|
||||||
char* buf = base::utils::Str::clearBuff(buff, base::consts::kSourceFilenameMaxLength + base::consts::kSourceLineMaxLength);
|
char* buf = base::utils::Str::clearBuff(buff, base::consts::kSourceFilenameMaxLength + base::consts::kSourceLineMaxLength);
|
||||||
base::utils::File::buildStrippedFilename(logMessage->file().c_str(), buff);
|
base::utils::File::buildStrippedFilename(logMessage->file().c_str(), buff, ELPP->vRegistry()->getFilenameCommonPrefix());
|
||||||
buf = base::utils::Str::addToBuff(buff, buf, bufLim);
|
buf = base::utils::Str::addToBuff(buff, buf, bufLim);
|
||||||
buf = base::utils::Str::addToBuff(":", buf, bufLim);
|
buf = base::utils::Str::addToBuff(":", buf, bufLim);
|
||||||
buf = base::utils::Str::convertAndAddToBuff(logMessage->line(), base::consts::kSourceLineMaxLength, buf, bufLim, false);
|
buf = base::utils::Str::convertAndAddToBuff(logMessage->line(), base::consts::kSourceLineMaxLength, buf, bufLim, false);
|
||||||
|
@ -6149,6 +6162,10 @@ el::base::type::ostream_t& operator<<(el::base::type::ostream_t& OutputStreamIns
|
||||||
static inline void clearCategories(void) {
|
static inline void clearCategories(void) {
|
||||||
ELPP->vRegistry()->clearCategories();
|
ELPP->vRegistry()->clearCategories();
|
||||||
}
|
}
|
||||||
|
/// @brief Sets filename common prefix
|
||||||
|
static inline void setFilenameCommonPrefix(const std::string &prefix) {
|
||||||
|
ELPP->vRegistry()->setFilenameCommonPrefix(prefix);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
class VersionInfo : base::StaticClass {
|
class VersionInfo : base::StaticClass {
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue