Skip to content

Commit

Permalink
Adds complete verbose mode to rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
NejcZdovc committed Nov 5, 2018
1 parent 972daf3 commit 05acf47
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ deps = {
"vendor/python-patch": "https://github.com/svn2github/python-patch@a336a458016ced89aba90dfc3f4c8222ae3b1403",
"vendor/omaha": "https://github.com/brave/omaha.git@5c633e867efafb9013c57ca830212d1ff6ea5076",
"vendor/sparkle": "https://github.com/brave/Sparkle.git@c0759cce415d7c0feae45005c8a013b1898711f0",
"vendor/bat-native-ledger": "https://github.com/brave-intl/bat-native-ledger@6c198464110bfb3e1969067807ce0794fef110af",
"vendor/bat-native-ledger": "https://github.com/brave-intl/bat-native-ledger@a8550e6bf36eba0d62b3f24409d1cf4edb20827b",
"vendor/bat-native-rapidjson": "https://github.com/brave-intl/bat-native-rapidjson.git@86aafe2ef89835ae71c9ed7c2527e3bb3000930e",
"vendor/bip39wally-core-native": "https://github.com/brave-intl/bip39wally-core-native.git@9b119931c702d55be994117eb505d56310720b1d",
"vendor/bat-native-anonize": "https://github.com/brave-intl/bat-native-anonize.git@adeff3254bb90ccdc9699040d5a4e1cd6b8393b7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,6 @@ sql::InitStatus PublisherInfoDatabase::EnsureCurrentVersion() {

// Migration from version 1 to version 2
if (old_version == 1 && cur_version == 2) {
LOG(ERROR) << "I am in DB!";
if (!MigrateV1toV2()) {
LOG(ERROR) << "DB: Error with MigrateV1toV2";
}
Expand Down
46 changes: 29 additions & 17 deletions components/brave_rewards/browser/rewards_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,6 @@ RewardsServiceImpl::RewardsServiceImpl(Profile* profile)
ledger::reconcile_time = defined_reconcile_int;
}
}

// Verbose mode
#if defined(NDEBUG)
ledger::is_verbose = false;
#else
ledger::is_verbose = true;
#endif
}

RewardsServiceImpl::~RewardsServiceImpl() {
Expand Down Expand Up @@ -489,7 +482,7 @@ void RewardsServiceImpl::RestorePublishers() {

void RewardsServiceImpl::OnMediaPublisherInfoSaved(bool success) {
if (!success) {
VLOG(1) << "Error in OnMediaPublisherInfoSaved";
LOG(ERROR) << "Error in OnMediaPublisherInfoSaved";
}
}

Expand Down Expand Up @@ -807,7 +800,7 @@ std::unique_ptr<ledger::LedgerURLLoader> RewardsServiceImpl::LoadURL(
if (!content.empty())
fetcher->SetUploadData(contentType, content);

if (VLOG_IS_ON(2)) {
if (VLOG_IS_ON(ledger::LogLevel::REQUEST)) {
std::string printMethod;
switch (method) {
case ledger::URL_METHOD::POST:
Expand All @@ -820,15 +813,15 @@ std::unique_ptr<ledger::LedgerURLLoader> RewardsServiceImpl::LoadURL(
printMethod = "GET";
break;
}
VLOG(2) << "[ REQUEST ]";
VLOG(2) << "> url: " << url;
VLOG(2) << "> method: " << printMethod;
VLOG(2) << "> content: " << content;
VLOG(2) << "> contentType: " << contentType;
VLOG(ledger::LogLevel::REQUEST) << "[ REQUEST ]";
VLOG(ledger::LogLevel::REQUEST) << "> url: " << url;
VLOG(ledger::LogLevel::REQUEST) << "> method: " << printMethod;
VLOG(ledger::LogLevel::REQUEST) << "> content: " << content;
VLOG(ledger::LogLevel::REQUEST) << "> contentType: " << contentType;
for (size_t i = 0; i < headers.size(); i++) {
VLOG(2) << "> headers: " << headers[i];
VLOG(ledger::LogLevel::REQUEST) << "> headers: " << headers[i];
}
VLOG(2) << "[ END REQUEST ]";
VLOG(ledger::LogLevel::REQUEST) << "[ END REQUEST ]";
}

FetchCallback callback = base::Bind(
Expand Down Expand Up @@ -1319,7 +1312,7 @@ void RewardsServiceImpl::FetchFavIcon(const std::string& url,
std::vector<std::string>::iterator it;
it = find (current_media_fetchers_.begin(), current_media_fetchers_.end(), url);
if (it != current_media_fetchers_.end()) {
VLOG(1) << "Already fetching favicon: " << url;
LOG(WARNING) << "Already fetching favicon: " << url;
return;
}

Expand Down Expand Up @@ -1605,4 +1598,23 @@ void RewardsServiceImpl::SetContributionAutoInclude(std::string publisher_key,
windowId);
}

void RewardsServiceImpl::Log(ledger::LogLevel level, const std::string& text) {
if (level == ledger::LogLevel::ERROR) {
LOG(ERROR) << text;
return;
}

if (level == ledger::LogLevel::WARNING) {
LOG(WARNING) << text;
return;
}

if (level == ledger::LogLevel::INFO) {
LOG(INFO) << text;
return;
}

VLOG(level) << text;
}

} // namespace brave_rewards
1 change: 1 addition & 0 deletions components/brave_rewards/browser/rewards_service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ class RewardsServiceImpl : public RewardsService,
const std::string& publisher_key,
const ledger::PUBLISHER_CATEGORY category) override;
void GetRecurringDonations(ledger::RecurringDonationCallback callback) override;
void Log(ledger::LogLevel level, const std::string& text) override;

void OnIOTaskComplete(std::function<void(void)> callback);

Expand Down

0 comments on commit 05acf47

Please sign in to comment.