[Libreoffice-commits] online.git: loolwsd/Admin.cpp loolwsd/DocumentBroker.hpp loolwsd/IoUtil.cpp loolwsd/Log.hpp loolwsd/LOOLForKit.cpp loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp loolwsd/Util.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Nov 14 05:24:23 UTC 2016
loolwsd/Admin.cpp | 2 +-
loolwsd/DocumentBroker.hpp | 2 +-
loolwsd/IoUtil.cpp | 2 +-
loolwsd/LOOLForKit.cpp | 8 ++++----
loolwsd/LOOLKit.cpp | 24 ++++++++++++------------
loolwsd/LOOLWSD.cpp | 8 ++++----
loolwsd/Log.hpp | 2 ++
loolwsd/Util.cpp | 6 ++++--
8 files changed, 29 insertions(+), 25 deletions(-)
New commits:
commit b7df3b50a92a55fc5a44c824c0f81353201b26ac
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sun Nov 13 11:59:34 2016 -0500
loolwsd: Log::syserror and Log::sysfatal now supported as macro
Change-Id: Ic07e7fb46e0b3e01db164e5812ef9256f149e5d9
Reviewed-on: https://gerrit.libreoffice.org/30822
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/Admin.cpp b/loolwsd/Admin.cpp
index 12b4c50..e8d9d3a 100644
--- a/loolwsd/Admin.cpp
+++ b/loolwsd/Admin.cpp
@@ -125,7 +125,7 @@ bool AdminRequestHandler::adminCommandHandler(const std::vector<char>& payload)
const auto pid = std::stoi(tokens[1]);
if (kill(pid, SIGINT) != 0 && kill(pid, 0) !=0)
{
- Log::syserror("Cannot terminate PID: " + tokens[0]);
+ LOG_SYS("Cannot terminate PID: " << tokens[0]);
}
}
catch(std::invalid_argument& exc)
diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp
index fc035f7..6906391 100644
--- a/loolwsd/DocumentBroker.hpp
+++ b/loolwsd/DocumentBroker.hpp
@@ -103,7 +103,7 @@ public:
LOG_INF("Killing child [" << _pid << "].");
if (kill(_pid, SIGINT) != 0 && kill(_pid, 0) != 0 && errno != ESRCH)
{
- Log::syserror("Cannot terminate lokit [" + std::to_string(_pid) + "]. Abandoning.");
+ LOG_SYS("Cannot terminate lokit [" << _pid << "]. Abandoning.");
}
}
}
diff --git a/loolwsd/IoUtil.cpp b/loolwsd/IoUtil.cpp
index 918cc54..9b2a787 100644
--- a/loolwsd/IoUtil.cpp
+++ b/loolwsd/IoUtil.cpp
@@ -206,7 +206,7 @@ ssize_t writeToPipe(int pipe, const char* buffer, ssize_t size)
if (errno == EINTR || errno == EAGAIN)
continue;
- Log::syserror("Failed to write to pipe. Data: [" + std::string(buffer, size) + "].");
+ LOG_SYS("Failed to write to pipe. Data: [" << std::string(buffer, size) << "].");
count = -1;
break;
}
diff --git a/loolwsd/LOOLForKit.cpp b/loolwsd/LOOLForKit.cpp
index 9529139..f234405 100644
--- a/loolwsd/LOOLForKit.cpp
+++ b/loolwsd/LOOLForKit.cpp
@@ -113,7 +113,7 @@ static bool haveCapability(cap_value_t capability)
if (caps == nullptr)
{
- Log::sysfatal("cap_get_proc() failed.");
+ LOG_SFL("cap_get_proc() failed.");
return false;
}
@@ -124,12 +124,12 @@ static bool haveCapability(cap_value_t capability)
{
if (cap_name)
{
- Log::sysfatal("cap_get_flag failed for " + std::string(cap_name) + ".");
+ LOG_SFL("cap_get_flag failed for " << cap_name << ".");
cap_free(cap_name);
}
else
{
- Log::sysfatal("cap_get_flag failed for capability " + std::to_string(capability) + ".");
+ LOG_SFL("cap_get_flag failed for capability " << capability << ".");
}
return false;
}
@@ -233,7 +233,7 @@ static int createLibreOfficeKit(const std::string& childRoot,
// Parent
if (pid < 0)
{
- Log::syserror("Fork failed.");
+ LOG_SYS("Fork failed.");
}
else
{
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 397dcc5..507ad94 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -146,8 +146,8 @@ namespace
File(newPath.parent()).createDirectories();
if (link(fpath, newPath.toString().c_str()) == -1)
{
- Log::syserror("link(\"" + std::string(fpath) + "\",\"" + newPath.toString() +
- "\") failed. Exiting.");
+ LOG_SYS("link(\"" << std::string(fpath) << "\",\"" <<
+ newPath.toString() << "\") failed. Exiting.");
std::_Exit(Application::EXIT_SOFTWARE);
}
break;
@@ -156,7 +156,7 @@ namespace
struct stat st;
if (stat(fpath, &st) == -1)
{
- Log::syserror("stat(\"" + std::string(fpath) + "\") failed.");
+ LOG_SYS("stat(\"" << std::string(fpath) << "\") failed.");
return 1;
}
if (!shouldCopyDir(relativeOldPath))
@@ -170,7 +170,7 @@ namespace
ut.modtime = st.st_mtime;
if (utime(newPath.toString().c_str(), &ut) == -1)
{
- Log::syserror("utime(\"" + newPath.toString() + "\") failed.");
+ LOG_SYS("utime(\"" << newPath.toString() << "\") failed.");
return 1;
}
}
@@ -210,7 +210,7 @@ namespace
caps = cap_get_proc();
if (caps == nullptr)
{
- Log::syserror("cap_get_proc() failed.");
+ LOG_SYS("cap_get_proc() failed.");
std::_Exit(1);
}
@@ -221,13 +221,13 @@ namespace
if (cap_set_flag(caps, CAP_EFFECTIVE, sizeof(cap_list)/sizeof(cap_list[0]), cap_list, CAP_CLEAR) == -1 ||
cap_set_flag(caps, CAP_PERMITTED, sizeof(cap_list)/sizeof(cap_list[0]), cap_list, CAP_CLEAR) == -1)
{
- Log::syserror("cap_set_flag() failed.");
+ LOG_SYS("cap_set_flag() failed.");
std::_Exit(1);
}
if (cap_set_proc(caps) == -1)
{
- Log::syserror("cap_set_proc() failed.");
+ LOG_SYS("cap_set_proc() failed.");
std::_Exit(1);
}
@@ -252,7 +252,7 @@ namespace
LOG_DBG("symlink(\"" << symlinkTarget << "\",\"" << symlinkSource.toString() << "\")");
if (symlink(symlinkTarget.c_str(), symlinkSource.toString().c_str()) == -1)
{
- Log::syserror("symlink(\"" + symlinkTarget + "\",\"" + symlinkSource.toString() + "\") failed");
+ LOG_SYS("symlink(\"" << symlinkTarget << "\",\"" << symlinkSource.toString() << "\") failed");
throw Exception("symlink() failed");
}
}
@@ -1388,25 +1388,25 @@ void lokit_main(const std::string& childRoot,
S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH,
makedev(1, 8)) != 0)
{
- Log::syserror("mknod(" + jailPath.toString() + "/dev/random) failed.");
+ LOG_SYS("mknod(" << jailPath.toString() << "/dev/random) failed.");
}
if (mknod((jailPath.toString() + "/dev/urandom").c_str(),
S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH,
makedev(1, 9)) != 0)
{
- Log::syserror("mknod(" + jailPath.toString() + "/dev/urandom) failed.");
+ LOG_SYS("mknod(" << jailPath.toString() << "/dev/urandom) failed.");
}
LOG_INF("chroot(\"" << jailPath.toString() << "\")");
if (chroot(jailPath.toString().c_str()) == -1)
{
- Log::syserror("chroot(\"" + jailPath.toString() + "\") failed.");
+ LOG_SYS("chroot(\"" << jailPath.toString() << "\") failed.");
std::_Exit(Application::EXIT_SOFTWARE);
}
if (chdir("/") == -1)
{
- Log::syserror("chdir(\"/\") in jail failed.");
+ LOG_SYS("chdir(\"/\") in jail failed.");
std::_Exit(Application::EXIT_SOFTWARE);
}
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 1563d6b..507c1a4 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -1862,7 +1862,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
{
std::string version, hash;
Util::getVersionInfo(version, hash);
- std::cout << "loolwsd version details: " << version << " - " << hash << std::endl;
+ LOG_INF("Loolwsd version details: " << version << " - " << hash);
}
initializeSSL();
@@ -1873,8 +1873,8 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
if (access(Cache.c_str(), R_OK | W_OK | X_OK) != 0)
{
- Log::sysfatal("Unable to access cache [" + Cache +
- "] please make sure it exists, and has write permission for this user.");
+ LOG_SFL("Unable to access cache [" << Cache <<
+ "] please make sure it exists, and has write permission for this user.");
return Application::EXIT_SOFTWARE;
}
@@ -2017,7 +2017,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
}
else if (pid < 0)
{
- Log::syserror("waitpid failed.");
+ LOG_SYS("waitpid failed.");
if (errno == ECHILD)
{
// No child processes.
diff --git a/loolwsd/Log.hpp b/loolwsd/Log.hpp
index 5435644..ebd0ba4 100644
--- a/loolwsd/Log.hpp
+++ b/loolwsd/Log.hpp
@@ -176,7 +176,9 @@ namespace Log
#define LOG_INF(X) if (Log::infoEnabled()) { LOG_BODY("INF", X); Log::logger().information(oss_.str()); }
#define LOG_WRN(X) if (Log::warnEnabled()) { LOG_BODY("WRN", X); Log::logger().warning(oss_.str()); }
#define LOG_ERR(X) if (Log::errorEnabled()) { LOG_BODY("ERR", X); Log::logger().error(oss_.str()); }
+#define LOG_SYS(X) if (Log::errorEnabled()) { LOG_BODY("ERR", X << " (errno: " << std::strerror(errno) << ")"); Log::logger().error(oss_.str()); }
#define LOG_FTL(X) if (Log::fatalEnabled()) { LOG_BODY("FTL", X); Log::logger().fatal(oss_.str()); }
+#define LOG_SFL(X) if (Log::errorEnabled()) { LOG_BODY("FTL", X << " (errno: " << std::strerror(errno) << ")"); Log::logger().fatal(oss_.str()); }
#endif
diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp
index 7949c09..e3a2b02 100644
--- a/loolwsd/Util.cpp
+++ b/loolwsd/Util.cpp
@@ -273,7 +273,7 @@ namespace Util
if (writev(STDERR_FILENO, ioVector, numSlots*2+1) == -1)
{
- Log::syserror("Failed to dump backtrace to stderr.");
+ LOG_SYS("Failed to dump backtrace to stderr.");
}
}
}
@@ -380,7 +380,9 @@ namespace Util
void setThreadName(const std::string& s)
{
if (prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(s.c_str()), 0, 0, 0) != 0)
- Log::syserror("Cannot set thread name to " + s + ".");
+ {
+ LOG_SYS("Cannot set thread name to " << s << ".");
+ }
}
void getVersionInfo(std::string& version, std::string& hash)
More information about the Libreoffice-commits
mailing list