aboutsummaryrefslogtreecommitdiff
path: root/external/easylogging++/easylogging++.cc
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-03-25 20:12:32 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-04-10 21:05:28 +0100
commit72663f4b8348bfcdd67886cfdd89a4ceb6779832 (patch)
tree3c1f5611bfc84a0a680c103f0a9f751f6b32ba92 /external/easylogging++/easylogging++.cc
parenteasylogging++: add file-only logs (diff)
downloadmonero-72663f4b8348bfcdd67886cfdd89a4ceb6779832.tar.xz
easylogging++: allow clipping a common filename prefix
Diffstat (limited to 'external/easylogging++/easylogging++.cc')
-rw-r--r--external/easylogging++/easylogging++.cc18
1 files changed, 15 insertions, 3 deletions
diff --git a/external/easylogging++/easylogging++.cc b/external/easylogging++/easylogging++.cc
index 1fca50678..3e8463fdf 100644
--- a/external/easylogging++/easylogging++.cc
+++ b/external/easylogging++/easylogging++.cc
@@ -767,7 +767,11 @@ std::string File::extractPathFromFilename(const std::string& fullPath, const cha
return fullPath.substr(0, lastSlashAt + 1);
}
-void File::buildStrippedFilename(const char* filename, char buff[], std::size_t limit) {
+void File::buildStrippedFilename(const char* filename, char buff[], const std::string &commonPrefix, std::size_t limit) {
+ if (!commonPrefix.empty()) {
+ if (!strncmp(filename, commonPrefix.c_str(), commonPrefix.size()))
+ filename += commonPrefix.size();
+ }
std::size_t sizeOfFilename = strlen(filename);
if (sizeOfFilename >= limit) {
filename += (sizeOfFilename - limit);
@@ -2394,7 +2398,7 @@ base::type::string_t DefaultLogBuilder::build(const LogMessage* logMessage, bool
if (logFormat->hasFlag(base::FormatFlags::File)) {
// File
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));
}
if (logFormat->hasFlag(base::FormatFlags::FileBase)) {
@@ -2413,7 +2417,7 @@ base::type::string_t DefaultLogBuilder::build(const LogMessage* logMessage, bool
// Location
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(":", buf, bufLim);
buf = base::utils::Str::convertAndAddToBuff(logMessage->line(), base::consts::kSourceLineMaxLength, buf, bufLim,
@@ -3072,6 +3076,14 @@ void Loggers::clearCategories(void) {
ELPP->vRegistry()->clearCategories();
}
+void Loggers::setFilenameCommonPrefix(const std::string &prefix) {
+ ELPP->vRegistry()->setFilenameCommonPrefix(prefix);
+}
+
+const std::string &Loggers::getFilenameCommonPrefix() {
+ return ELPP->vRegistry()->getFilenameCommonPrefix();
+}
+
// VersionInfo
const std::string VersionInfo::version(void) {