[Libreoffice-commits] online.git: loolwsd/Log.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Wed Aug 31 04:37:14 UTC 2016
loolwsd/Log.cpp | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
New commits:
commit 492268913b50c97f4f55199a1b135ae6f9eea920
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Tue Aug 30 14:42:57 2016 -0400
loolwsd: grep-friendly logs
Log entries now prefix the log-level so
it is now trivial to filter-in or -out
a particular class of logs (for example
errors).
Change-Id: I8033d1780a49dd8a3244e63f867377f0c64e9d9f
Reviewed-on: https://gerrit.libreoffice.org/28520
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/Log.cpp b/loolwsd/Log.cpp
index 3471b4b..0c327df 100644
--- a/loolwsd/Log.cpp
+++ b/loolwsd/Log.cpp
@@ -69,7 +69,7 @@ namespace Log
}
}
- static void getPrefix(char *buffer)
+ static void getPrefix(char *buffer, const char* level)
{
Poco::Int64 usec = Poco::Timestamp().epochMicroseconds() - epochStart;
@@ -88,23 +88,23 @@ namespace Log
const char *appName = (Source.inited ? Source.id.c_str() : "<shutdown>");
assert(strlen(appName) + 32 + 28 < 1024 - 1);
- snprintf(buffer, 4095, "%s-%.2d %.2d:%.2d:%.2d.%.6d [ %s ] ", appName,
+ snprintf(buffer, 4095, "%s-%.2d %d:%.2d:%.2d.%.6d [ %s ] %s ", appName,
(Poco::Thread::current() ? Poco::Thread::current()->id() : 0),
(int)hours, (int)minutes, (int)seconds, (int)usec,
- procName);
+ procName, level);
}
- std::string prefix()
+ std::string prefix(const char* level)
{
char buffer[1024];
- getPrefix(buffer);
+ getPrefix(buffer, level);
return std::string(buffer);
}
void signalLogPrefix()
{
char buffer[1024];
- getPrefix(buffer);
+ getPrefix(buffer, "SIG");
signalLog(buffer);
}
@@ -157,32 +157,32 @@ namespace Log
void trace(const std::string& msg)
{
- logger().trace(prefix() + msg);
+ logger().trace(prefix("TRC") + msg);
}
void debug(const std::string& msg)
{
- logger().debug(prefix() + msg);
+ logger().debug(prefix("DBG") + msg);
}
void info(const std::string& msg)
{
- logger().information(prefix() + msg);
+ logger().information(prefix("INF") + msg);
}
void warn(const std::string& msg)
{
- logger().warning(prefix() + msg);
+ logger().warning(prefix("WRN") + msg);
}
void error(const std::string& msg)
{
- logger().error(prefix() + msg);
+ logger().error(prefix("ERR") + msg);
}
void syserror(const std::string& msg)
{
- logger().error(prefix() + msg + " (errno: " + std::string(std::strerror(errno)) + ")");
+ logger().error(prefix("SYS") + msg + " (errno: " + std::string(std::strerror(errno)) + ")");
}
}
More information about the Libreoffice-commits
mailing list