xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
xrpld
rpc
handlers
admin
log
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
16
namespace
xrpl
{
17
18
json::Value
19
doLogLevel
(
rpc::JsonContext
& context)
20
{
21
// log_level
22
if
(not context.
params
.
isMember
(jss::severity))
23
{
24
// get log severities
25
json::Value
ret(
json::ValueType::Object
);
26
json::Value
lev(
json::ValueType::Object
);
27
28
lev[jss::base] =
Logs::toString
(context.
app
.
getLogs
().
threshold
());
29
std::vector<std::pair<std::string, std::string>
>
const
logTable(
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
38
auto
const
severity =
Logs::fromString
(context.
params
[jss::severity].
asString
());
39
40
if
(not severity.has_value())
41
return
rpcError
(
RpcInvalidParams
);
42
43
// log_level severity
44
if
(not context.
params
.
isMember
(jss::partition))
45
{
46
// set base log threshold
47
context.
app
.
getLogs
().
threshold
(*severity);
48
return
json::ValueType::Object
;
49
}
50
51
// log_level partition severity base?
52
if
(context.
params
.
isMember
(jss::partition))
53
{
54
// set partition threshold
55
std::string
const
partition(context.
params
[jss::partition].
asString
());
56
57
if
(boost::iequals(partition,
"base"
))
58
{
59
context.
app
.
getLogs
().
threshold
(*severity);
60
}
61
else
62
{
63
context.
app
.
getLogs
().
get
(partition).
threshold
(*severity);
64
}
65
66
return
json::ValueType::Object
;
67
}
68
69
return
rpcError
(
RpcInvalidParams
);
70
}
71
72
}
// namespace xrpl
std::string
beast::Journal::Sink::threshold
virtual Severity threshold() const
Returns the minimum severity level this sink will report.
Definition
beast_Journal.cpp:96
json::Value
Represents a JSON value.
Definition
json_value.h:117
json::Value::asString
std::string asString() const
Returns the unquoted string value.
Definition
json_value.cpp:494
json::Value::isMember
bool isMember(char const *key) const
Return true if the object has a member named key.
Definition
json_value.cpp:1049
xrpl::Logs::partitionSeverities
std::vector< std::pair< std::string, std::string > > partitionSeverities() const
Definition
Log.cpp:158
xrpl::Logs::toString
static std::string toString(beast::Severity s)
Definition
Log.cpp:203
xrpl::Logs::get
beast::Journal::Sink & get(std::string const &name)
Definition
Log.cpp:123
xrpl::Logs::threshold
beast::Severity threshold() const
Definition
Log.cpp:143
xrpl::Logs::fromString
static std::optional< beast::Severity > fromString(std::string const &s)
Definition
Log.cpp:228
xrpl::ServiceRegistry::getLogs
virtual Logs & getLogs()=0
json::ValueType::Object
@ Object
object value (collection of name/value pairs).
Definition
json_value.h:29
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::RpcInvalidParams
@ RpcInvalidParams
Definition
ErrorCodes.h:67
xrpl::rpcError
json::Value rpcError(ErrorCodeI iError)
Definition
RPCErr.cpp:13
xrpl::doLogLevel
json::Value doLogLevel(rpc::JsonContext &context)
Definition
LogLevel.cpp:19
string
xrpl::rpc::Context::app
Application & app
Definition
Context.h:29
xrpl::rpc::JsonContext
Definition
Context.h:41
xrpl::rpc::JsonContext::params
json::Value params
Definition
Context.h:51
utility
vector
Generated by
1.17.0