Commit b4970c27 authored by Ivan Vilata-i-Balaguer's avatar Ivan Vilata-i-Balaguer
Browse files

Remove separate log level setting from cache client.

And setting it from client front-end.  The announcer still needs to get its
previously inherited log level setting removed.
parent 80865b65
......@@ -93,20 +93,18 @@ struct Client::Impl {
GarbageCollector _gc;
map<string, udp::endpoint> _peer_cache;
util::LruCache<std::string, shared_ptr<DhtLookup>> _dht_lookups;
log_level_t _log_level = INFO;
LocalPeerDiscovery _local_peer_discovery;
std::unique_ptr<DhtGroups> _dht_groups;
bool log_debug() const { return _log_level <= DEBUG || logger.get_log_file(); }
bool log_info() const { return _log_level <= INFO || logger.get_log_file(); }
bool log_debug() const { return logger.get_threshold() <= DEBUG || logger.get_log_file(); }
bool log_info() const { return logger.get_threshold() <= INFO || logger.get_log_file(); }
Impl( shared_ptr<bt::MainlineDht> dht_
, util::Ed25519PublicKey& cache_pk
, fs::path cache_dir
, unique_ptr<cache::HttpStore> http_store_
, boost::posix_time::time_duration max_cached_age
, log_level_t log_level)
, boost::posix_time::time_duration max_cached_age)
: _newest_proto_seen(std::make_shared<unsigned>(http_::protocol_version_current))
, _ex(dht_->get_executor())
, _dht(move(dht_))
......@@ -116,12 +114,11 @@ struct Client::Impl {
, _cache_dir(move(cache_dir))
, _http_store(move(http_store_))
, _max_cached_age(max_cached_age)
, _announcer(_dht, log_level)
, _announcer(_dht, logger.get_threshold())
, _gc(*_http_store, [&] (auto rr, auto y) {
return keep_cache_entry(move(rr), y);
}, _ex)
, _dht_lookups(256)
, _log_level(log_level)
, _local_peer_discovery(_ex, _dht->local_endpoints())
{}
......@@ -517,14 +514,6 @@ struct Client::Impl {
std::set<std::string> get_announced_groups() const {
return _dht_groups->groups();
}
void set_log_level(log_level_t l) {
cerr << "Setting cache/client Cache log level to " << l << "\n";
_log_level = l;
_announcer.set_log_level(l);
}
log_level_t get_log_level() const { return _log_level; }
};
/* static */
......@@ -533,7 +522,6 @@ Client::build( shared_ptr<bt::MainlineDht> dht
, util::Ed25519PublicKey cache_pk
, fs::path cache_dir
, boost::posix_time::time_duration max_cached_age
, log_level_t log_level
, asio::yield_context yield)
{
using ClientPtr = unique_ptr<Client>;
......@@ -559,8 +547,7 @@ Client::build( shared_ptr<bt::MainlineDht> dht
unique_ptr<Impl> impl(new Impl( move(dht)
, cache_pk, move(cache_dir)
, move(http_store), max_cached_age
, log_level));
, move(http_store), max_cached_age));
impl->announce_stored_data(yield[ec]);
if (ec) return or_throw<ClientPtr>(yield, ec);
......@@ -617,16 +604,6 @@ std::set<std::string> Client::get_announced_groups() const
return _impl->get_announced_groups();
}
void Client::set_log_level(log_level_t l)
{
_impl->set_log_level(l);
}
log_level_t Client::get_log_level() const
{
return _impl->get_log_level();
}
Client::~Client()
{
_impl->stop();
......
#pragma once
#include "../../logger.h"
#include "../../response_reader.h"
#include "../../util/crypto.h"
#include "../../util/yield.h"
......@@ -29,7 +28,6 @@ public:
, util::Ed25519PublicKey cache_pk
, fs::path cache_dir
, boost::posix_time::time_duration max_cached_age
, log_level_t
, asio::yield_context);
// This may add a response source header.
......@@ -66,9 +64,6 @@ public:
~Client();
void set_log_level(log_level_t);
log_level_t get_log_level() const;
private:
Client(std::unique_ptr<Impl>);
......
......@@ -2206,7 +2206,6 @@ void Client::State::setup_cache()
, *_config.cache_http_pub_key()
, _config.repo_root()/"bep5_http"
, _config.max_cached_age()
, logger.get_threshold()
, yield[ec]);
if (cancel) ec = asio::error::operation_aborted;
......
......@@ -150,7 +150,6 @@ static ostream& operator<<(ostream& os, const ClientFrontEnd::Task& task) {
ClientFrontEnd::ClientFrontEnd()
: _log_level_input(new Input<log_level_t>("Log level", "loglevel", { SILLY, DEBUG, VERBOSE, INFO, WARN, ERROR, ABORT }, logger.get_threshold()))
, _cache_log_level_input(new Input<log_level_t>("Bep5Http log level", "bep5_loglevel", { SILLY, DEBUG, VERBOSE, INFO, WARN, ERROR, ABORT }, INFO))
{}
void ClientFrontEnd::handle_ca_pem( const Request& req, Response& res, stringstream& ss
......@@ -217,13 +216,6 @@ void ClientFrontEnd::handle_portal( ClientConfig& config
_log_level_no_file = _log_level_input->current_value;
}
if (cache_client) {
_cache_log_level_input->current_value = cache_client->get_log_level();
if (_cache_log_level_input->update(target)) {
cache_client->set_log_level(_cache_log_level_input->current_value);
}
}
if (target.find('?') != string::npos) {
// XXX: Extra primitive value parsing.
if (target.find("?origin_access=enable") != string::npos) {
......@@ -339,8 +331,6 @@ void ClientFrontEnd::handle_portal( ClientConfig& config
}
if (cache_client) {
ss << *_cache_log_level_input;
auto max_age = config.max_cached_age();
ss << ( boost::format("Content cached locally if newer than %d seconds"
" (i.e. not older than %s).<br>\n")
......
......@@ -92,7 +92,6 @@ private:
boost::optional<log_level_t> _log_level_no_file;
std::unique_ptr<Input<log_level_t>> _log_level_input;
std::unique_ptr<Input<log_level_t>> _cache_log_level_input;
boost::intrusive::list
< Task
......
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