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 ripple {
13
16{
17 // log_level
18 if (!context.params.isMember(jss::severity))
19 {
20 // get log severities
23
24 lev[jss::base] =
27 context.app.logs().partition_severities());
28 for (auto const& [k, v] : logTable)
29 lev[k] = v;
30
31 ret[jss::levels] = lev;
32 return ret;
33 }
34
35 LogSeverity const sv(
36 Logs::fromString(context.params[jss::severity].asString()));
37
38 if (sv == lsINVALID)
40
41 auto severity = Logs::toSeverity(sv);
42 // log_level severity
43 if (!context.params.isMember(jss::partition))
44 {
45 // set base log threshold
46 context.app.logs().threshold(severity);
47 return Json::objectValue;
48 }
49
50 // log_level partition severity base?
51 if (context.params.isMember(jss::partition))
52 {
53 // set partition threshold
54 std::string partition(context.params[jss::partition].asString());
55
56 if (boost::iequals(partition, "base"))
57 context.app.logs().threshold(severity);
58 else
59 context.app.logs().get(partition).threshold(severity);
60
61 return Json::objectValue;
62 }
63
65}
66
67} // namespace ripple
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::Journal::Sink & get(std::string const &name)
Definition Log.cpp:127
static LogSeverity fromString(std::string const &s)
Definition Log.cpp:289
beast::severities::Severity threshold() const
Definition Log.cpp:147
static std::string toString(LogSeverity s)
Definition Log.cpp:264
static beast::severities::Severity toSeverity(LogSeverity level)
Definition Log.cpp:236
std::vector< std::pair< std::string, std::string > > partition_severities() const
Definition Log.cpp:162
static LogSeverity fromSeverity(beast::severities::Severity level)
Definition Log.cpp:207
@ 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
@ rpcINVALID_PARAMS
Definition ErrorCodes.h:65
Json::Value rpcError(int iError)
Definition RPCErr.cpp:12
Json::Value doLogLevel(RPC::JsonContext &)
Definition LogLevel.cpp:15
LogSeverity
Definition Log.h:19
@ lsINVALID
Definition Log.h:20
Application & app
Definition Context.h:22