Skip to content

Commit add2dd9

Browse files
committed
kernel: remove unused logging functions
As logging is struct-based, there is no more need for the user to configure how logs are printed, so simplify the interface and remove dead code.
1 parent 7791941 commit add2dd9

File tree

6 files changed

+0
-77
lines changed

6 files changed

+0
-77
lines changed

src/bitcoin-chainstate.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,6 @@ int main(int argc, char* argv[])
161161
std::filesystem::path abs_datadir{std::filesystem::absolute(argv[argc-1])};
162162
std::filesystem::create_directories(abs_datadir);
163163

164-
btck_LoggingOptions logging_options = {
165-
.log_timestamps = true,
166-
.log_time_micros = false,
167-
.log_threadnames = false,
168-
.log_sourcelocations = false,
169-
.always_print_category_levels = true,
170-
};
171-
172-
logging_set_options(logging_options);
173-
174164
Logger logger{std::make_unique<KernelLog>()};
175165

176166
ContextOptions options{};

src/kernel/bitcoinkernel.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -751,16 +751,6 @@ void btck_txid_destroy(btck_Txid* txid)
751751
delete txid;
752752
}
753753

754-
void btck_logging_set_options(const btck_LoggingOptions options)
755-
{
756-
LOCK(cs_main);
757-
LogInstance().m_log_timestamps = options.log_timestamps;
758-
LogInstance().m_log_time_micros = options.log_time_micros;
759-
LogInstance().m_log_threadnames = options.log_threadnames;
760-
LogInstance().m_log_sourcelocations = options.log_sourcelocations;
761-
LogInstance().m_always_print_category_level = options.always_print_category_levels;
762-
}
763-
764754
void btck_logging_set_level_category(btck_LogCategory category, btck_LogLevel level)
765755
{
766756
LOCK(cs_main);
@@ -781,11 +771,6 @@ void btck_logging_disable_category(btck_LogCategory category)
781771
LogInstance().DisableCategory(get_bclog_flag(category));
782772
}
783773

784-
void btck_logging_disable()
785-
{
786-
LogInstance().DisableLogging();
787-
}
788-
789774
btck_LoggingConnection* btck_logging_connection_create(btck_LogCallback callback, void* user_data, btck_DestroyCallback user_data_destroy_callback)
790775
{
791776
assert(callback);

src/kernel/bitcoinkernel.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -467,19 +467,6 @@ typedef struct {
467467
btck_NotifyFatalError fatal_error; //!< An unrecoverable system error encountered by the library.
468468
} btck_NotificationInterfaceCallbacks;
469469

470-
/**
471-
* Options controlling the format of log messages.
472-
*
473-
* Set fields as non-zero to indicate true.
474-
*/
475-
typedef struct {
476-
int log_timestamps; //!< Prepend a timestamp to log messages.
477-
int log_time_micros; //!< Log timestamps in microsecond precision.
478-
int log_threadnames; //!< Prepend the name of the thread to log messages.
479-
int log_sourcelocations; //!< Prepend the source location to log messages.
480-
int always_print_category_levels; //!< Prepend the log category and level to log messages.
481-
} btck_LoggingOptions;
482-
483470
/**
484471
* A collection of status codes that may be issued by the script verify function.
485472
*/
@@ -776,25 +763,6 @@ BITCOINKERNEL_API void btck_transaction_output_destroy(btck_TransactionOutput* t
776763
*/
777764
///@{
778765

779-
/**
780-
* @brief This disables the global internal logger. No log messages will be
781-
* buffered internally anymore once this is called and the buffer is cleared.
782-
* This function should only be called once and is not thread or re-entry safe.
783-
* Log messages will be buffered until this function is called, or a logging
784-
* connection is created. This must not be called while a logging connection
785-
* already exists.
786-
*/
787-
BITCOINKERNEL_API void btck_logging_disable();
788-
789-
/**
790-
* @brief Set some options for the global internal logger. This changes global
791-
* settings and will override settings for all existing @ref
792-
* btck_LoggingConnection instances.
793-
*
794-
* @param[in] options Sets formatting options of the log messages.
795-
*/
796-
BITCOINKERNEL_API void btck_logging_set_options(btck_LoggingOptions options);
797-
798766
/**
799767
* @brief Set the log level of the global internal logger. This does not
800768
* enable the selected categories. Use @ref btck_logging_enable_category to

src/kernel/bitcoinkernel_wrapper.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -810,16 +810,6 @@ class Block : public Handle<btck_Block, btck_block_copy, btck_block_destroy>
810810
}
811811
};
812812

813-
inline void logging_disable()
814-
{
815-
btck_logging_disable();
816-
}
817-
818-
inline void logging_set_options(const btck_LoggingOptions& logging_options)
819-
{
820-
btck_logging_set_options(logging_options);
821-
}
822-
823813
inline void logging_set_level_category(LogCategory category, LogLevel level)
824814
{
825815
btck_logging_set_level_category(static_cast<btck_LogCategory>(category), static_cast<btck_LogLevel>(level));

src/logging.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ namespace BCLog {
284284
/** Disable logging
285285
* This offers a slight speedup and slightly smaller memory usage
286286
* compared to leaving the logging system in its default state.
287-
* Mostly intended for libbitcoin-kernel apps that don't want any logging.
288287
* Should be used instead of StartLogging().
289288
*/
290289
void DisableLogging() EXCLUSIVE_LOCKS_REQUIRED(!m_cs);

src/test/kernel/test_kernel.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -615,15 +615,6 @@ BOOST_AUTO_TEST_CASE(btck_script_verify_tests)
615615

616616
BOOST_AUTO_TEST_CASE(logging_tests)
617617
{
618-
btck_LoggingOptions logging_options = {
619-
.log_timestamps = true,
620-
.log_time_micros = true,
621-
.log_threadnames = false,
622-
.log_sourcelocations = false,
623-
.always_print_category_levels = true,
624-
};
625-
626-
logging_set_options(logging_options);
627618
logging_set_level_category(LogCategory::BENCH, LogLevel::TRACE_LEVEL);
628619
logging_disable_category(LogCategory::BENCH);
629620
logging_enable_category(LogCategory::VALIDATION);

0 commit comments

Comments
 (0)