diff options
author | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2023-02-07 21:42:57 +0000 |
---|---|---|
committer | Andrey Lihatskiy <alihatskiy@productengine.com> | 2023-03-20 22:39:48 +0200 |
commit | 72cec2d347e9240cd08706ff5155bc29822e2ad8 (patch) | |
tree | 7ff0a94304936b79f7a535621c455bbb84fcf62f /indra | |
parent | dca3c83cd9f8d1ac8165707b080a420bf9a9a132 (diff) |
SL-19161 - logging of basic translation stats in ViewerStats
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/lltranslate.cpp | 49 | ||||
-rw-r--r-- | indra/newview/lltranslate.h | 16 | ||||
-rw-r--r-- | indra/newview/llviewermessage.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llviewerstats.cpp | 3 |
4 files changed, 71 insertions, 1 deletions
diff --git a/indra/newview/lltranslate.cpp b/indra/newview/lltranslate.cpp index 4b9f322dfa..34d3ed8bb1 100644 --- a/indra/newview/lltranslate.cpp +++ b/indra/newview/lltranslate.cpp @@ -546,6 +546,18 @@ void LLBingTranslationHandler::verifyKey(const std::string &key, LLTranslate::Ke } //========================================================================= +LLTranslate::LLTranslate(): + mCharsSeen(0), + mCharsSent(0), + mFailureCount(0), + mSuccessCount(0) +{ +} + +LLTranslate::~LLTranslate() +{ +} + /*static*/ void LLTranslate::translateMessage(const std::string &from_lang, const std::string &to_lang, const std::string &mesg, TranslationSuccess_fn success, TranslationFailure_fn failure) @@ -634,6 +646,43 @@ bool LLTranslate::isTranslationConfigured() return getPreferredHandler().isConfigured(); } +void LLTranslate::logCharsSeen(size_t count) +{ + mCharsSeen += count; +} + +void LLTranslate::logCharsSent(size_t count) +{ + mCharsSent += count; +} + +void LLTranslate::logSuccess(S32 count) +{ + mSuccessCount += count; +} + +void LLTranslate::logFailure(S32 count) +{ + mFailureCount += count; +} + +LLSD LLTranslate::asLLSD() const +{ + LLSD res; + bool on = gSavedSettings.getBOOL("TranslateChat"); + res["on"] = on; + res["chars_seen"] = (S32) mCharsSeen; + if (on) + { + res["chars_sent"] = (S32) mCharsSent; + res["success_count"] = mSuccessCount; + res["failure_count"] = mFailureCount; + res["language"] = getTranslateLanguage(); + res["service"] = gSavedSettings.getString("TranslationService"); + } + return res; +} + // static LLTranslationAPIHandler& LLTranslate::getPreferredHandler() { diff --git a/indra/newview/lltranslate.h b/indra/newview/lltranslate.h index e0722fbd83..58707e2d36 100644 --- a/indra/newview/lltranslate.h +++ b/indra/newview/lltranslate.h @@ -30,6 +30,8 @@ #include "llbufferstream.h" #include <boost/function.hpp> +#include "llsingleton.h" + namespace Json { class Value; @@ -48,8 +50,10 @@ class LLTranslationAPIHandler; * * API keys for translation are taken from saved settings. */ -class LLTranslate +class LLTranslate: public LLSingleton<LLTranslate> { + LLSINGLETON(LLTranslate); + ~LLTranslate(); LOG_CLASS(LLTranslate); public : @@ -94,9 +98,19 @@ public : static std::string addNoTranslateTags(std::string mesg); static std::string removeNoTranslateTags(std::string mesg); + void logCharsSeen(size_t count); + void logCharsSent(size_t count); + void logSuccess(S32 count); + void logFailure(S32 count); + LLSD asLLSD() const; private: static LLTranslationAPIHandler& getPreferredHandler(); static LLTranslationAPIHandler& getHandler(EService service); + + size_t mCharsSeen; + size_t mCharsSent; + S32 mFailureCount; + S32 mSuccessCount; }; #endif diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 17d4f1928c..c1a9b6be80 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -2426,6 +2426,7 @@ void translateSuccess(LLChat chat, LLSD toastArgs, std::string originalMsg, std: chat.mText += " (" + LLTranslate::removeNoTranslateTags(translation) + ")"; } + LLTranslate::instance().logSuccess(1); LLNotificationsUI::LLNotificationManager::instance().onChat(chat, toastArgs); } @@ -2435,6 +2436,7 @@ void translateFailure(LLChat chat, LLSD toastArgs, int status, const std::string LLStringUtil::replaceString(msg, "\n", " "); // we want one-line error messages chat.mText += " (" + msg + ")"; + LLTranslate::instance().logFailure(1); LLNotificationsUI::LLNotificationManager::instance().onChat(chat, toastArgs); } @@ -2669,6 +2671,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) LLSD args; chat.mOwnerID = owner_id; + LLTranslate::instance().logCharsSeen(mesg.size()); if (gSavedSettings.getBOOL("TranslateChat") && chat.mSourceType != CHAT_SOURCE_SYSTEM) { if (chat.mChatStyle == CHAT_STYLE_IRC) @@ -2678,6 +2681,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) const std::string from_lang = ""; // leave empty to trigger autodetect const std::string to_lang = LLTranslate::getTranslateLanguage(); + LLTranslate::instance().logCharsSent(mesg.size()); LLTranslate::translateMessage(from_lang, to_lang, mesg, boost::bind(&translateSuccess, chat, args, mesg, from_lang, _1, _2), boost::bind(&translateFailure, chat, args, _1, _2)); diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index df3db9bb1d..0f2b0714fd 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -64,6 +64,7 @@ #include "llvoicevivox.h" #include "llinventorymodel.h" #include "lluiusage.h" +#include "lltranslate.h" namespace LLStatViewer { @@ -500,6 +501,7 @@ void send_viewer_stats(bool include_preferences) agent["meters_traveled"] = gAgent.getDistanceTraveled(); agent["regions_visited"] = gAgent.getRegionsVisited(); agent["mem_use"] = LLMemory::getCurrentRSS() / 1024.0; + agent["translation"] = LLTranslate::instance().asLLSD(); LLSD &system = body["system"]; @@ -531,6 +533,7 @@ void send_viewer_stats(bool include_preferences) gGLManager.asLLSD(system["gl"]); + S32 shader_level = 0; if (LLPipeline::sRenderDeferred) { |