Skip to content

Commit

Permalink
refactor: Move error() from util/system.h to logging.h
Browse files Browse the repository at this point in the history
error is a low-level function with a sole dependency on LogPrintf, which
is defined in logging.h

The background of this commit is an ongoing effort to decouple the
libbitcoinkernel library from the ArgsManager defined in system.h.
Moving the function out of system.h allows including it from a separate
source file without including the ArgsManager definitions from system.h.
  • Loading branch information
Empact authored and TheCharlatan committed Mar 13, 2023
1 parent e7333b4 commit aaced56
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/addrdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <cstdint>
#include <fs.h>
#include <hash.h>
#include <logging.h>
#include <logging/timer.h>
#include <netbase.h>
#include <netgroup.h>
Expand Down
1 change: 1 addition & 0 deletions src/index/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <index/base.h>
#include <interfaces/chain.h>
#include <kernel/chain.h>
#include <logging.h>
#include <node/blockstorage.h>
#include <node/context.h>
#include <node/database_args.h>
Expand Down
1 change: 1 addition & 0 deletions src/index/coinstatsindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <crypto/muhash.h>
#include <index/coinstatsindex.h>
#include <kernel/coinstats.h>
#include <logging.h>
#include <node/blockstorage.h>
#include <serialize.h>
#include <txdb.h>
Expand Down
1 change: 1 addition & 0 deletions src/index/txindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <index/txindex.h>

#include <index/disktxpos.h>
#include <logging.h>
#include <node/blockstorage.h>
#include <util/system.h>
#include <validation.h>
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/coinstats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <coins.h>
#include <crypto/muhash.h>
#include <hash.h>
#include <logging.h>
#include <node/blockstorage.h>
#include <primitives/transaction.h>
#include <script/script.h>
Expand All @@ -19,7 +20,6 @@
#include <uint256.h>
#include <util/check.h>
#include <util/overflow.h>
#include <util/system.h>
#include <validation.h>
#include <version.h>

Expand Down
7 changes: 7 additions & 0 deletions src/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,11 @@ static inline void LogPrintf_(const std::string& logging_function, const std::st
} \
} while (0)

template <typename... Args>
bool error(const char* fmt, const Args&... args)
{
LogPrintf("ERROR: %s\n", tfm::format(fmt, args...));
return false;
}

#endif // BITCOIN_LOGGING_H
3 changes: 2 additions & 1 deletion src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
#include <compat/compat.h>
#include <consensus/consensus.h>
#include <crypto/sha256.h>
#include <node/eviction.h>
#include <fs.h>
#include <i2p.h>
#include <logging.h>
#include <net_permissions.h>
#include <netaddress.h>
#include <netbase.h>
#include <node/eviction.h>
#include <node/interface_ui.h>
#include <protocol.h>
#include <random.h>
Expand Down
2 changes: 1 addition & 1 deletion src/netbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
#include <netbase.h>

#include <compat/compat.h>
#include <logging.h>
#include <sync.h>
#include <tinyformat.h>
#include <util/sock.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <util/system.h>
#include <util/time.h>

#include <atomic>
Expand Down
1 change: 1 addition & 0 deletions src/node/blockstorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <flatfile.h>
#include <fs.h>
#include <hash.h>
#include <logging.h>
#include <pow.h>
#include <reverse_iterator.h>
#include <shutdown.h>
Expand Down
2 changes: 1 addition & 1 deletion src/script/signingprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <script/signingprovider.h>
#include <script/standard.h>

#include <util/system.h>
#include <logging.h>

const SigningProvider& DUMMY_SIGNING_PROVIDER = SigningProvider();

Expand Down
2 changes: 1 addition & 1 deletion src/txdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#include <txdb.h>

#include <chain.h>
#include <logging.h>
#include <pow.h>
#include <random.h>
#include <shutdown.h>
#include <uint256.h>
#include <util/system.h>
#include <util/translation.h>
#include <util/vector.h>

Expand Down
7 changes: 0 additions & 7 deletions src/util/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ extern const char * const BITCOIN_SETTINGS_FILENAME;
void SetupEnvironment();
bool SetupNetworking();

template<typename... Args>
bool error(const char* fmt, const Args&... args)
{
LogPrintf("ERROR: %s\n", tfm::format(fmt, args...));
return false;
}

/**
* Ensure file contents are fully committed to disk, using a platform-specific
* feature analogous to fsync().
Expand Down

0 comments on commit aaced56

Please sign in to comment.