Skip to content

Commit fa894b0

Browse files
author
MarcoFalke
committed
log: Properly log warnings with warn loglevel in addrdb
1 parent 83ae780 commit fa894b0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/addrdb.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) 2009-2010 Satoshi Nakamoto
2-
// Copyright (c) 2009-2022 The Bitcoin Core developers
2+
// Copyright (c) 2009-present The Bitcoin Core developers
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

@@ -155,7 +155,7 @@ bool CBanDB::Write(const banmap_t& banSet)
155155
bool CBanDB::Read(banmap_t& banSet)
156156
{
157157
if (fs::exists(m_banlist_dat)) {
158-
LogPrintf("banlist.dat ignored because it can only be read by " CLIENT_NAME " version 22.x. Remove %s to silence this warning.\n", fs::quoted(fs::PathToString(m_banlist_dat)));
158+
LogWarning("banlist.dat ignored because it can only be read by " CLIENT_NAME " version 22.x. Remove %s to silence this warning.", fs::quoted(fs::PathToString(m_banlist_dat)));
159159
}
160160
// If the JSON banlist does not exist, then recreate it
161161
if (!fs::exists(m_banlist_json)) {
@@ -167,15 +167,15 @@ bool CBanDB::Read(banmap_t& banSet)
167167

168168
if (!common::ReadSettings(m_banlist_json, settings, errors)) {
169169
for (const auto& err : errors) {
170-
LogPrintf("Cannot load banlist %s: %s\n", fs::PathToString(m_banlist_json), err);
170+
LogWarning("Cannot load banlist %s: %s", fs::PathToString(m_banlist_json), err);
171171
}
172172
return false;
173173
}
174174

175175
try {
176176
BanMapFromJson(settings[JSON_KEY], banSet);
177177
} catch (const std::runtime_error& e) {
178-
LogPrintf("Cannot parse banlist %s: %s\n", fs::PathToString(m_banlist_json), e.what());
178+
LogWarning("Cannot parse banlist %s: %s", fs::PathToString(m_banlist_json), e.what());
179179
return false;
180180
}
181181

@@ -204,19 +204,19 @@ util::Result<std::unique_ptr<AddrMan>> LoadAddrman(const NetGroupManager& netgro
204204
const auto path_addr{args.GetDataDirNet() / "peers.dat"};
205205
try {
206206
DeserializeFileDB(path_addr, *addrman);
207-
LogPrintf("Loaded %i addresses from peers.dat %dms\n", addrman->Size(), Ticks<std::chrono::milliseconds>(SteadyClock::now() - start));
207+
LogInfo("Loaded %i addresses from peers.dat %dms", addrman->Size(), Ticks<std::chrono::milliseconds>(SteadyClock::now() - start));
208208
} catch (const DbNotFoundError&) {
209209
// Addrman can be in an inconsistent state after failure, reset it
210210
addrman = std::make_unique<AddrMan>(netgroupman, deterministic, /*consistency_check_ratio=*/check_addrman);
211-
LogPrintf("Creating peers.dat because the file was not found (%s)\n", fs::quoted(fs::PathToString(path_addr)));
211+
LogInfo("Creating peers.dat because the file was not found (%s)", fs::quoted(fs::PathToString(path_addr)));
212212
DumpPeerAddresses(args, *addrman);
213213
} catch (const InvalidAddrManVersionError&) {
214214
if (!RenameOver(path_addr, (fs::path)path_addr + ".bak")) {
215215
return util::Error{strprintf(_("Failed to rename invalid peers.dat file. Please move or delete it and try again."))};
216216
}
217217
// Addrman can be in an inconsistent state after failure, reset it
218218
addrman = std::make_unique<AddrMan>(netgroupman, deterministic, /*consistency_check_ratio=*/check_addrman);
219-
LogPrintf("Creating new peers.dat because the file version was not compatible (%s). Original backed up to peers.dat.bak\n", fs::quoted(fs::PathToString(path_addr)));
219+
LogWarning("Creating new peers.dat because the file version was not compatible (%s). Original backed up to peers.dat.bak", fs::quoted(fs::PathToString(path_addr)));
220220
DumpPeerAddresses(args, *addrman);
221221
} catch (const std::exception& e) {
222222
return util::Error{strprintf(_("Invalid or corrupt peers.dat (%s). If you believe this is a bug, please report it to %s. As a workaround, you can move the file (%s) out of the way (rename, move, or delete) to have a new one created on the next start."),
@@ -236,7 +236,7 @@ std::vector<CAddress> ReadAnchors(const fs::path& anchors_db_path)
236236
std::vector<CAddress> anchors;
237237
try {
238238
DeserializeFileDB(anchors_db_path, CAddress::V2_DISK(anchors));
239-
LogPrintf("Loaded %i addresses from %s\n", anchors.size(), fs::quoted(fs::PathToString(anchors_db_path.filename())));
239+
LogInfo("Loaded %i addresses from %s", anchors.size(), fs::quoted(fs::PathToString(anchors_db_path.filename())));
240240
} catch (const std::exception&) {
241241
anchors.clear();
242242
}

0 commit comments

Comments
 (0)