Commit 61c03c90 authored by Pavel Vainerman's avatar Pavel Vainerman

(codegen):(Http API): добавил команду /log для вывода текущего

уровня включённых логов.
parent 682169f9
......@@ -256,8 +256,9 @@
// HTTP API
virtual nlohmann::json httpGet( const Poco::URI::QueryParameters& p ) override;
virtual nlohmann::json httpDumpIO();
virtual nlohmann::json httpRequest( const std::string& req, const Poco::URI::QueryParameters& p ) override;
virtual nlohmann::json httpHelp( const Poco::URI::QueryParameters& p ) override;
</xsl:template>
<xsl:template name="COMMON-HEAD-PROTECTED">
......@@ -271,8 +272,10 @@
virtual bool activateObject() override;
virtual std::string getMonitInfo(){ return ""; } /*!&lt; пользовательская информация выводимая в getInfo() */
virtual void httpGetUserData( nlohmann::json&amp; jdata ){} /*!&lt; для пользовательских данных в httpGet() */
// Выполнение очередного шага программы
virtual nlohmann::json httpDumpIO();
virtual nlohmann::json httpRequestLog( const Poco::URI::QueryParameters&amp; p );
// Выполнение очередного шага программы
virtual void step(){}
void preAskSensors( UniversalIO::UIOCommand cmd );
......@@ -564,8 +567,7 @@ nlohmann::json <xsl:value-of select="$CLASSNAME"/>_SK::httpGet( const Poco::URI:
<xsl:if test="not(normalize-space($BASECLASS)='')">nlohmann::json json = <xsl:value-of select="$BASECLASS"/>::httpGet(params);</xsl:if>
<xsl:if test="normalize-space($BASECLASS)=''">nlohmann::json json = UniSetObject::httpGet(params);</xsl:if>
std::string myid(to_string(getId()));
auto&amp; jdata = json[myid];
auto&amp; jdata = json[myname];
if( logserv )
{
......@@ -620,6 +622,36 @@ nlohmann::json <xsl:value-of select="$CLASSNAME"/>_SK::httpGet( const Poco::URI:
return std::move(json);
}
// -----------------------------------------------------------------------------
nlohmann::json <xsl:value-of select="$CLASSNAME"/>_SK::httpHelp( const Poco::URI::QueryParameters&amp; params )
{
<xsl:if test="not(normalize-space($BASECLASS)='')">nlohmann::json jdata = <xsl:value-of select="$BASECLASS"/>::httpHelp(params);</xsl:if>
<xsl:if test="normalize-space($BASECLASS)=''">nlohmann::json jdata = UniSetObject::httpGet(params);</xsl:if>
auto&amp; jhelp = jdata[myname]["help"];
jhelp["log"]["desc"] = "show log level";
return jdata;
}
// -----------------------------------------------------------------------------
nlohmann::json <xsl:value-of select="$CLASSNAME"/>_SK::httpRequest( const std::string&amp; req, const Poco::URI::QueryParameters&amp; p )
{
if( req == "log" )
return httpRequestLog(p);
<xsl:if test="not(normalize-space($BASECLASS)='')">return <xsl:value-of select="$BASECLASS"/>::httpRequest(req,p);</xsl:if>
<xsl:if test="normalize-space($BASECLASS)=''">return UniSetObject::httpRequest(req,p);</xsl:if>
}
// -----------------------------------------------------------------------------
nlohmann::json <xsl:value-of select="$CLASSNAME"/>_SK::httpRequestLog( const Poco::URI::QueryParameters&amp; p )
{
nlohmann::json jret;
auto&amp; jdata = jret[myname];
jdata["log"] = Debug::str(mylog->level());
return std::move(jret);
}
// -----------------------------------------------------------------------------
<xsl:if test="normalize-space($TESTMODE)!=''">
bool <xsl:value-of select="$CLASSNAME"/>_SK::checkTestMode() const noexcept
{
......
......@@ -382,9 +382,7 @@ void UniSetObject::push( const TransportMessage& tm )
nlohmann::json UniSetObject::httpGet( const Poco::URI::QueryParameters& p )
{
nlohmann::json jret;
std::string myid(to_string(getId()));
auto& jdata = jret[myid];
auto& jdata = jret[myname];
jdata["name"] = myname;
jdata["id"] = getId();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment