rippled
Loading...
Searching...
No Matches
LogLevel.cpp
1#include <xrpld/app/main/Application.h>
2#include <xrpld/rpc/Context.h>
3
4#include <xrpl/basics/Log.h>
5#include <xrpl/json/json_value.h>
6#include <xrpl/protocol/ErrorCodes.h>
7#include <xrpl/protocol/RPCErr.h>
8#include <xrpl/protocol/jss.h>
9
10#include <boost/algorithm/string/predicate.hpp>
11
12namespace xrpl {
13
16{
17 // log_level
18 if (!context.params.isMember(jss::severity))
19 {
20 // get log severities
23
24 lev[jss::base] = Logs::toString(Logs::fromSeverity(context.app.logs().threshold()));
26 for (auto const& [k, v] : logTable)
27 lev[k] = v;
28
29 ret[jss::levels] = lev;
30 return ret;
31 }
32
33 LogSeverity const sv(Logs::fromString(context.params[jss::severity].asString()));
34
35 if (sv == lsINVALID)
37
38 auto severity = Logs::toSeverity(sv);
39 // log_level severity
40 if (!context.params.isMember(jss::partition))
41 {
42 // set base log threshold
43 context.app.logs().threshold(severity);
44 return Json::objectValue;
45 }
46
47 // log_level partition severity base?
48 if (context.params.isMember(jss::partition))
49 {
50 // set partition threshold
51 std::string partition(context.params[jss::partition].asString());
52
53 if (boost::iequals(partition, "base"))
54 context.app.logs().threshold(severity);
55 else
56 context.app.logs().get(partition).threshold(severity);
57
58 return Json::objectValue;
59 }
60
62}
63
64} // namespace xrpl
Represents a JSON value.
Definition json_value.h:131
std::string asString() const
Returns the unquoted string value.
bool isMember(char const *key) const
Return true if the object has a member named key.
virtual Severity threshold() const
Returns the minimum severity level this sink will report.
virtual Logs & logs()=0
beast::severities::Severity threshold() const
Definition Log.cpp:140
beast::Journal::Sink & get(std::string const &name)
Definition Log.cpp:120
static LogSeverity fromSeverity(beast::severities::Severity level)
Definition Log.cpp:196
std::vector< std::pair< std::string, std::string > > partition_severities() const
Definition Log.cpp:155
static LogSeverity fromString(std::string const &s)
Definition Log.cpp:278
static std::string toString(LogSeverity s)
Definition Log.cpp:253
static beast::severities::Severity toSeverity(LogSeverity level)
Definition Log.cpp:225
@ objectValue
object value (collection of name/value pairs).
Definition json_value.h:27
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
Json::Value doLogLevel(RPC::JsonContext &)
Definition LogLevel.cpp:15
LogSeverity
Definition Log.h:19
@ lsINVALID
Definition Log.h:20
Json::Value rpcError(error_code_i iError)
Definition RPCErr.cpp:12
@ rpcINVALID_PARAMS
Definition ErrorCodes.h:65
Application & app
Definition Context.h:22
Json::Value params
Definition Context.h:44