xrpld
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
12#include <string>
13#include <utility>
14#include <vector>
15
16namespace xrpl {
17
18json::Value
20{
21 // log_level
22 if (not context.params.isMember(jss::severity))
23 {
24 // get log severities
27
28 lev[jss::base] = Logs::toString(context.app.getLogs().threshold());
30 context.app.getLogs().partitionSeverities());
31 for (auto const& [k, v] : logTable)
32 lev[k] = v;
33
34 ret[jss::levels] = lev;
35 return ret;
36 }
37 if (not context.params[jss::severity].isString())
39
40 auto const severity = Logs::fromString(context.params[jss::severity].asString());
41
42 if (not severity.has_value())
44
45 // log_level severity
46 if (not context.params.isMember(jss::partition))
47 {
48 // set base log threshold
49 context.app.getLogs().threshold(*severity);
51 }
52
53 // log_level partition severity base?
54 if (context.params.isMember(jss::partition))
55 {
56 if (not context.params[jss::partition].isString())
58 // set partition threshold
59 std::string const partition(context.params[jss::partition].asString());
60
61 if (boost::iequals(partition, "base"))
62 {
63 context.app.getLogs().threshold(*severity);
64 }
65 else
66 {
67 context.app.getLogs().get(partition).threshold(*severity);
68 }
69
71 }
72
74}
75
76} // namespace xrpl
virtual Severity threshold() const
Returns the minimum severity level this sink will report.
Represents a JSON value.
Definition json_value.h:121
bool isString() const
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.
std::vector< std::pair< std::string, std::string > > partitionSeverities() const
Definition Log.cpp:158
static std::string toString(beast::Severity s)
Definition Log.cpp:203
beast::Journal::Sink & get(std::string const &name)
Definition Log.cpp:123
beast::Severity threshold() const
Definition Log.cpp:143
static std::optional< beast::Severity > fromString(std::string const &s)
Definition Log.cpp:228
virtual Logs & getLogs()=0
@ Object
object value (collection of name/value pairs).
Definition json_value.h:33
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
@ RpcInvalidParams
Definition ErrorCodes.h:67
json::Value rpcError(ErrorCodeI iError)
Definition RPCErr.cpp:13
json::Value doLogLevel(rpc::JsonContext &context)
Definition LogLevel.cpp:19
Application & app
Definition Context.h:29
json::Value params
Definition Context.h:51