SL-14862 - use nested LLSD for widget info, condensed to the two leaf-most elements of the path. Simplified floater logging.

master
Brad Payne (Vir Linden) 2021-03-10 16:23:20 +00:00
parent dd89dec893
commit 89bd426901
5 changed files with 35 additions and 10 deletions

View File

@ -58,6 +58,7 @@
#include "llhelp.h"
#include "llmultifloater.h"
#include "llsdutil.h"
#include "lluiusage.h"
#include <boost/foreach.hpp>
@ -1631,6 +1632,7 @@ void LLFloater::bringToFront( S32 x, S32 y )
// virtual
void LLFloater::setVisibleAndFrontmost(BOOL take_focus,const LLSD& key)
{
LLUIUsage::instance().logFloater(getInstanceName());
LLMultiFloater* hostp = getHost();
if (hostp)
{

View File

@ -244,8 +244,6 @@ LLFloaterReg::const_instance_list_t& LLFloaterReg::getFloaterList(const std::str
//static
LLFloater* LLFloaterReg::showInstance(const std::string& name, const LLSD& key, BOOL focus)
{
LL_DEBUGS("UIUsage") << "floater showInstance " << name << LL_ENDL;
LLUIUsage::instance().logFloater(name);
if( sBlockShowFloaters
// see EXT-7090
&& sAlwaysShowableList.find(name) == sAlwaysShowableList.end())
@ -276,9 +274,6 @@ bool LLFloaterReg::hideInstance(const std::string& name, const LLSD& key)
// returns true if the instance is visible when completed
bool LLFloaterReg::toggleInstance(const std::string& name, const LLSD& key)
{
LL_DEBUGS("UIUsage") << "floater toggleInstance " << name << LL_ENDL;
LLUIUsage::instance().logFloater(name);
LLFloater* instance = findInstance(name, key);
if (LLFloater::isShown(instance))
{
@ -478,9 +473,6 @@ void LLFloaterReg::toggleInstanceOrBringToFront(const LLSD& sdname, const LLSD&
std::string name = sdname.asString();
LLFloater* instance = getInstance(name, key);
LL_DEBUGS("UIUsage") << "floater toggleInstanceOrBringToFront " << name << LL_ENDL;
LLUIUsage::instance().logFloater(name);
if (!instance)
{
LL_DEBUGS() << "Unable to get instance of floater '" << name << "'" << LL_ENDL;

View File

@ -26,6 +26,7 @@
#include "linden_common.h"
#include "lluiusage.h"
#include <boost/algorithm/string.hpp>
LLUIUsage::LLUIUsage()
{
@ -41,9 +42,39 @@ std::string LLUIUsage::sanitized(const std::string& s)
// ViewerStats db doesn't like "." in keys
std::string result(s);
std::replace(result.begin(), result.end(), '.', '_');
std::replace(result.begin(), result.end(), ' ', '_');
return result;
}
void LLUIUsage::setLLSDNested(LLSD& sd, const std::string& path, S32 max_elts, S32 val) const
{
std::vector<std::string> fields;
boost::split(fields, path, boost::is_any_of("/"));
auto first_pos = std::max(fields.begin(), fields.end() - max_elts);
auto end_pos = fields.end();
std::vector<std::string> last_fields(first_pos,end_pos);
// Code below is just to accomplish the equivalent of
// sd[last_fields[0]][last_fields[1]] = LLSD::Integer(val);
// for an arbitrary number of fields.
LLSD* fsd = &sd;
for (auto it=last_fields.begin(); it!=last_fields.end(); ++it)
{
if (it == last_fields.end()-1)
{
(*fsd)[*it] = LLSD::Integer(val);
}
else
{
if (!(*fsd)[*it].isMap())
{
(*fsd)[*it] = LLSD::emptyMap();
}
fsd = &(*fsd)[*it];
}
}
}
void LLUIUsage::logFloater(const std::string& floater)
{
mFloaterCounts[sanitized(floater)]++;
@ -75,7 +106,7 @@ LLSD LLUIUsage::asLLSD() const
}
for (auto const& it : mWidgetCounts)
{
result["widgets"][it.first] = LLSD::Integer(it.second);
setLLSDNested(result["widgets"], it.first, 2, it.second);
}
return result;
}

View File

@ -39,6 +39,7 @@ public:
~LLUIUsage();
public:
static std::string sanitized(const std::string& s);
void setLLSDNested(LLSD& sd, const std::string& path, S32 max_elts, S32 val) const;
void logFloater(const std::string& floater);
void logCommand(const std::string& command);
void logWidget(const std::string& w);

View File

@ -116,7 +116,6 @@
#include "llviewerregion.h"
#include "llfloaterregionrestarting.h"
#include <boost/algorithm/string/split.hpp> //
#include <boost/foreach.hpp>
#include "llnotificationmanager.h" //