summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGökay Şatır <gokaysatir@collabora.com>2020-11-23 14:07:44 +0300
committerAshod Nakashian <Ashod@users.noreply.github.com>2020-12-07 17:30:51 -0500
commitb51413c0a0144b483d441df99ffb00a5da7fe44a (patch)
tree016129ab3fa43bc8fa05baf88f0c5cc3d9819525
parentAdmin console log levels. (diff)
downloadonline-b51413c0a0144b483d441df99ffb00a5da7fe44a.tar.gz
online-b51413c0a0144b483d441df99ffb00a5da7fe44a.zip
Admin console: Cosmetic changes and documentation.
Change-Id: I977b5bc56f44c44b8bedf9f9bd710e7050fe67ff Signed-off-by: Gökay Şatır <gokaysatir@collabora.com>
-rw-r--r--kit/ForKit.cpp4
-rw-r--r--loleaflet/admin/adminLog.html24
-rw-r--r--wsd/Admin.cpp12
-rw-r--r--wsd/Admin.hpp4
-rw-r--r--wsd/DocumentBroker.cpp8
-rw-r--r--wsd/DocumentBroker.hpp3
-rw-r--r--wsd/LOOLWSD.cpp7
-rw-r--r--wsd/LOOLWSD.hpp1
8 files changed, 32 insertions, 31 deletions
diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp
index 9d1960426d..a16a44adef 100644
--- a/kit/ForKit.cpp
+++ b/kit/ForKit.cpp
@@ -152,11 +152,11 @@ protected:
LOG_WRN("Cannot spawn " << tokens[1] << " children as requested.");
}
}
- else if (tokens.size() == 2 && tokens.equals(0, "setloglevel"))
+ else if (tokens.size() == 2 && tokens.equals(0, "setloglevel"))
{
// Set environment variable so that new children will also set their log levels accordingly.
setenv("LOOL_LOGLEVEL", tokens[1].c_str(), true);
- Log::logger().setLevel(tokens[1]);
+ Log::logger().setLevel(tokens[1]);
}
else if (tokens.size() == 3 && tokens.equals(0, "setconfig"))
{
diff --git a/loleaflet/admin/adminLog.html b/loleaflet/admin/adminLog.html
index 6d15d8d7d6..c0bbdedc4c 100644
--- a/loleaflet/admin/adminLog.html
+++ b/loleaflet/admin/adminLog.html
@@ -9,21 +9,19 @@
<button type="button" id="button-open-log-list-modal" class="button is-info" style="width:120px;">
<script>document.write(l10nstrings.strSetLogLevels)</script>
</button>
- </div>
-
- <div class="level is-fullwidth is-mobile">
- <div class="field is-horizontal">
- <label class="field-label" style="vertical-align: middle; line-height:30px;"><script>document.write(l10nstrings.strChannelFilter)</script></label>
- <div class="control">
- <select class="select" id="log-channel-filter">
- <option><script>document.write(l10nstrings.strChannelFilterNone)</script></option>
- </select>
- </div>
- </div>
- </div>
+ </div>
+ <div class="level is-fullwidth is-mobile">
+ <div class="field is-horizontal">
+ <label class="field-label" style="vertical-align: middle; line-height:30px;"><script>document.write(l10nstrings.strChannelFilter)</script></label>
+ <div class="control">
+ <select class="select" id="log-channel-filter">
+ <option><script>document.write(l10nstrings.strChannelFilterNone)</script></option>
+ </select>
+ </div>
+ </div>
+ </div>
<textarea id="log-lines" style="width:100%;height:100%;min-height: calc(100vh - 250px);resize:vertical;" readonly="true"></textarea>
-
</div>
</main>
diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index 3cc0728042..cfca8c6ed0 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -41,7 +41,7 @@ using Poco::Util::Application;
const int Admin::MinStatsIntervalMs = 50;
const int Admin::DefStatsIntervalMs = 1000;
-
+const std::string levelList[] = {"none", "fatal", "critical", "error", "warning", "notice", "information", "debug", "trace"};
/// Process incoming websocket messages
void AdminSocketHandler::handleMessage(const std::vector<char> &payload)
@@ -603,11 +603,10 @@ unsigned Admin::getNetStatsInterval()
std::string Admin::getChannelLogLevels()
{
- std::string levelList[9] = {"none", "fatal", "critical", "error", "warning", "notice", "information", "debug", "trace"};
unsigned int wsdLogLevel = Log::logger().get("wsd").getLevel();
- std::string result = "wsd=" + levelList[wsdLogLevel];
+ std::string result = "wsd=" + levelList[wsdLogLevel];
- result += " kits=" + (_forkitLogLevel != "" ? _forkitLogLevel: levelList[wsdLogLevel]);
+ result += " kits=" + (_forkitLogLevel.empty() != true ? _forkitLogLevel: levelList[wsdLogLevel]);
return result;
}
@@ -620,7 +619,6 @@ void Admin::setChannelLogLevel(const std::string& _channelName, std::string leve
std::vector<std::string> nameList;
Log::logger().names(nameList);
- std::string levelList[9] = {"none", "fatal", "critical", "error", "warning", "notice", "information", "debug", "trace"};
if (std::find(std::begin(levelList), std::end(levelList), level) == std::end(levelList))
level = "trace";
@@ -629,8 +627,8 @@ void Admin::setChannelLogLevel(const std::string& _channelName, std::string leve
else if (_channelName == "kits")
{
LOOLWSD::setLogLevelsOfKits(level); // For current kits.
- LOOLWSD::sendMessageToForKit("setloglevel " + level); // For forkit and future kits.
- _forkitLogLevel = level; // We will remember this setting rather than asking forkit its loglevel.
+ LOOLWSD::sendMessageToForKit("setloglevel " + level); // For forkit and future kits.
+ _forkitLogLevel = level; // We will remember this setting rather than asking forkit its loglevel.
}
}
diff --git a/wsd/Admin.hpp b/wsd/Admin.hpp
index cfa3e06df9..65fb9c7b80 100644
--- a/wsd/Admin.hpp
+++ b/wsd/Admin.hpp
@@ -103,8 +103,10 @@ public:
unsigned getNetStatsInterval();
+ /// Returns the log levels of wsd and forkit & kits.
std::string getChannelLogLevels();
+ /// Sets the specified channel's log level (wsd or forkit and kits).
void setChannelLogLevel(const std::string& _channelName, std::string _level);
std::string getLogLines();
@@ -172,7 +174,7 @@ private:
uint64_t _lastRecvCount;
size_t _totalSysMemKb;
size_t _totalAvailMemKb;
- std::string _forkitLogLevel = "";
+ std::string _forkitLogLevel;
struct MonitorConnectRecord
{
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index fc0f0bcbf8..8450642378 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1720,11 +1720,11 @@ void DocumentBroker::alertAllUsers(const std::string& msg)
}
}
-void DocumentBroker::setLogLevel(const std::string& level)
+void DocumentBroker::setKitLogLevel(const std::string& level)
{
- assertCorrectThread();
- std::unique_lock<std::mutex> lock(_mutex);
- _childProcess->sendTextFrame("setloglevel " + level);
+ assertCorrectThread();
+ std::unique_lock<std::mutex> lock(_mutex);
+ _childProcess->sendTextFrame("setloglevel " + level);
}
std::string DocumentBroker::getDownloadURL(const std::string& downloadId)
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 789c97f7e5..acbb262b33 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -229,7 +229,8 @@ public:
alertAllUsers("error: cmd=" + cmd + " kind=" + kind);
}
- void setLogLevel(const std::string& level);
+ /// Sets the log level of kit.
+ void setKitLogLevel(const std::string& level);
/// Invalidate the cursor position.
void invalidateCursor(int x, int y, int w, int h)
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index dd455aa9b0..34f531957d 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1796,16 +1796,17 @@ void LOOLWSD::autoSave(const std::string& docKey)
}
}
-void LOOLWSD::setLogLevelsOfKits(const std::string& level) {
+void LOOLWSD::setLogLevelsOfKits(const std::string& level)
+{
std::lock_guard<std::mutex> docBrokersLock(DocBrokersMutex);
LOG_INF("Changing kits' log levels: [" << level << ']');
- for (auto& brokerIt : DocBrokers)
+ for (const auto& brokerIt : DocBrokers)
{
std::shared_ptr<DocumentBroker> docBroker = brokerIt.second;
docBroker->addCallback([docBroker, level]() {
- docBroker->setLogLevel(level);
+ docBroker->setKitLogLevel(level);
});
}
}
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 6ccf8e2f20..79210cc46f 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -405,6 +405,7 @@ public:
/// Autosave a given document (currently only called from Admin).
static void autoSave(const std::string& docKey);
+ /// Sets the log level of current kits.
static void setLogLevelsOfKits(const std::string& level);
/// Anonymize the basename of filenames, preserving the path and extension.