forked from organicmaps/organicmaps
[tips_api] add logging
This commit is contained in:
parent
f86d391d56
commit
032601d317
2 changed files with 68 additions and 15 deletions
|
@ -4,8 +4,10 @@
|
|||
|
||||
#include "platform/platform.hpp"
|
||||
|
||||
#include "base/logging.hpp"
|
||||
#include "base/timer.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
|
@ -47,6 +49,13 @@ boost::optional<eye::Tip::Type> GetTipImpl(TipsApi::Duration showAnyTipPeriod,
|
|||
}
|
||||
|
||||
auto const info = Eye::Instance().GetInfo();
|
||||
|
||||
CHECK(info, ("Eye info must be initialized"));
|
||||
LOG(LINFO, ("Eye info ptr use count:", info.use_count(), "Info", *info, "Info::m_booking ref:",
|
||||
&(info->m_booking), "Info::m_bookmarks ref:", &(info->m_bookmarks), "Info::m_discovery ref:",
|
||||
&(info->m_discovery), "Info::m_layers ref:", &(info->m_layers), "Info::m_tips ref:",
|
||||
&(info->m_tips)));
|
||||
|
||||
auto const & tips = info->m_tips;
|
||||
auto constexpr totalTipsCount = static_cast<size_t>(Tip::Type::Count);
|
||||
|
||||
|
@ -78,7 +87,22 @@ boost::optional<eye::Tip::Type> GetTipImpl(TipsApi::Duration showAnyTipPeriod,
|
|||
for (auto const & c : candidates)
|
||||
{
|
||||
if (c.second && conditions[ToIndex(c.first)](*info))
|
||||
{
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "Condition for tip " << DebugPrint(c.first)
|
||||
<< " returns true. Previously shown tips: [ ";
|
||||
for (auto const & candidate : candidates)
|
||||
{
|
||||
if (!candidate.second)
|
||||
os << DebugPrint(candidate.first) << " ";
|
||||
}
|
||||
os << "]";
|
||||
LOG(LINFO, (os.str()));
|
||||
}
|
||||
|
||||
return c.first;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,10 +188,12 @@ TipsApi::TipsApi(Delegate const & delegate)
|
|||
{
|
||||
for (auto const & layer : info.m_layers)
|
||||
{
|
||||
if (layer.m_type == Layer::Type::PublicTransport &&
|
||||
layer.m_lastTimeUsed.time_since_epoch().count() != 0)
|
||||
if (layer.m_type == Layer::Type::PublicTransport)
|
||||
{
|
||||
return false;
|
||||
if (layer.m_lastTimeUsed.time_since_epoch().count() != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,19 +68,28 @@ enum class Version : int8_t
|
|||
Latest = V0
|
||||
};
|
||||
|
||||
inline std::string DebugPrint(Version const & version)
|
||||
{
|
||||
switch (version)
|
||||
{
|
||||
case Version::Unknown: return "Unknown";
|
||||
case Version::V0: return "V0";
|
||||
}
|
||||
}
|
||||
|
||||
using Clock = std::chrono::system_clock;
|
||||
using Time = Clock::time_point;
|
||||
|
||||
struct Booking
|
||||
{
|
||||
DECLARE_VISITOR(visitor(m_lastFilterUsedTime, "last_filter_used_time"))
|
||||
DECLARE_VISITOR_AND_DEBUG_PRINT(Booking, visitor(m_lastFilterUsedTime, "last_filter_used_time"))
|
||||
|
||||
Time m_lastFilterUsedTime;
|
||||
};
|
||||
|
||||
struct Bookmarks
|
||||
{
|
||||
DECLARE_VISITOR(visitor(m_lastOpenedTime, "last_use_time"))
|
||||
DECLARE_VISITOR_AND_DEBUG_PRINT(Bookmarks, visitor(m_lastOpenedTime, "last_use_time"))
|
||||
|
||||
Time m_lastOpenedTime;
|
||||
};
|
||||
|
@ -102,9 +111,9 @@ struct Discovery
|
|||
Count
|
||||
};
|
||||
|
||||
DECLARE_VISITOR(visitor(m_eventCounters, "event_counters"),
|
||||
visitor(m_lastOpenedTime, "last_opened_time"),
|
||||
visitor(m_lastClickedTime, "last_clicked_time"))
|
||||
DECLARE_VISITOR_AND_DEBUG_PRINT(Discovery, visitor(m_eventCounters, "event_counters"),
|
||||
visitor(m_lastOpenedTime, "last_opened_time"),
|
||||
visitor(m_lastClickedTime, "last_clicked_time"))
|
||||
|
||||
Counters<Event, uint32_t> m_eventCounters;
|
||||
Time m_lastOpenedTime;
|
||||
|
@ -119,8 +128,8 @@ struct Layer
|
|||
PublicTransport
|
||||
};
|
||||
|
||||
DECLARE_VISITOR(visitor(m_type, "type"), visitor(m_useCount, "use_count"),
|
||||
visitor(m_lastTimeUsed, "last_time_used"))
|
||||
DECLARE_VISITOR_AND_DEBUG_PRINT(Layer, visitor(m_type, "type"), visitor(m_useCount, "use_count"),
|
||||
visitor(m_lastTimeUsed, "last_time_used"))
|
||||
|
||||
Type m_type;
|
||||
uint64_t m_useCount = 0;
|
||||
|
@ -151,8 +160,9 @@ struct Tip
|
|||
Count
|
||||
};
|
||||
|
||||
DECLARE_VISITOR(visitor(m_type, "type"), visitor(m_eventCounters, "event_counters"),
|
||||
visitor(m_lastShownTime, "last_shown_time"))
|
||||
DECLARE_VISITOR_AND_DEBUG_PRINT(Tip, visitor(m_type, "type"),
|
||||
visitor(m_eventCounters, "event_counters"),
|
||||
visitor(m_lastShownTime, "last_shown_time"))
|
||||
|
||||
Type m_type;
|
||||
Counters<Event, uint32_t> m_eventCounters;
|
||||
|
@ -261,9 +271,10 @@ using MapObjects = m4::Tree<MapObject>;
|
|||
struct InfoV0
|
||||
{
|
||||
static Version GetVersion() { return Version::V0; }
|
||||
DECLARE_VISITOR(visitor(m_booking, "booking"), visitor(m_bookmarks, "bookmarks"),
|
||||
visitor(m_discovery, "discovery"), visitor(m_layers, "layers"),
|
||||
visitor(m_tips, "tips"))
|
||||
DECLARE_VISITOR_AND_DEBUG_PRINT(InfoV0, visitor(m_booking, "booking"),
|
||||
visitor(m_bookmarks, "bookmarks"),
|
||||
visitor(m_discovery, "discovery"), visitor(m_layers, "layers"),
|
||||
visitor(m_tips, "tips"))
|
||||
|
||||
Booking m_booking;
|
||||
Bookmarks m_bookmarks;
|
||||
|
@ -306,6 +317,22 @@ inline std::string DebugPrint(Layer::Type const & type)
|
|||
}
|
||||
}
|
||||
|
||||
inline std::string DebugPrint(Discovery::Event const & event)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case Discovery::Event::HotelsClicked: return "HotelsClicked";
|
||||
case Discovery::Event::AttractionsClicked: return "AttractionsClicked";
|
||||
case Discovery::Event::CafesClicked: return "CafesClicked";
|
||||
case Discovery::Event::LocalsClicked: return "LocalsClicked";
|
||||
case Discovery::Event::MoreHotelsClicked: return "MoreHotelsClicked";
|
||||
case Discovery::Event::MoreAttractionsClicked: return "MoreAttractionsClicked";
|
||||
case Discovery::Event::MoreCafesClicked: return "MoreCafesClicked";
|
||||
case Discovery::Event::MoreLocalsClicked: return "MoreLocalsClicked";
|
||||
case Discovery::Event::Count: return "Count";
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string DebugPrint(MapObject::Event::Type const & type)
|
||||
{
|
||||
switch (type)
|
||||
|
|
Loading…
Add table
Reference in a new issue