Add more descriptive logs (via stdout) during initialization

The C++ configure/initialize routines were particularly opaque
This commit is contained in:
John Colvin committed 2024-02-08 19:04:12 -06:00
1 parent 9382807fe8
commit d09ed6a8dd
3 files changed
+17 -5

No files matched your search

+5 -5
View File
@@ -3,13 +3,13 @@ using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace bts
{
public static class BTS
{
namespace bts {
public static class BTS {
static int _needs_init_spark_lib = 0;
public static void init(string config_source = null) {
Console.WriteLine(
$"Configuring BTS with {(config_source is null ? "defaults" : $"'{config_source}'")}");
var args = Environment.GetCommandLineArgs();
utils.BTSNativeMethods.provide_command_line(args, args.Length);
@@ -20,7 +20,7 @@ namespace bts
throw new ApplicationException(buffer.ToString());
}
if (Interlocked.CompareExchange(ref _needs_init_spark_lib,1,0) == 0) {
if (Interlocked.CompareExchange(ref _needs_init_spark_lib, 1, 0) == 0) {
utils.BTSNativeMethods.init_spark_lib();
}
+6
View File
@@ -79,6 +79,9 @@ void LoggerHub::config(const LoggingConfig &cfg) {
}
void LoggerHub::start() {
std::cout << "Starting LoggerHub '" << me->logger_name << "' on thread "
<< os::get_thread_name() << ":" << std::this_thread::get_id()
<< std::endl;
bts_assert(!me->worker);
me->worker = std::make_unique<std::thread>(threading::make_thread(
me->logger_name.c_str(), std::bind(&LoggerHub::do_work, this),
@@ -100,6 +103,9 @@ Logger &LoggerHub::make_logger() {
}
void LoggerHub::do_work() {
std::cout << "Starting LoggerHub '" << me->logger_name
<< "' worker on thread " << os::get_thread_name() << ":"
<< std::this_thread::get_id() << std::endl;
while (!me->done) {
size_t consumed = 0;
{
+6
View File
@@ -9,8 +9,14 @@ namespace utils {
static log::LoggingConfigPoller *poller = nullptr;
void init_spark_lib() {
// Write to stdout instead of normal log, because the logging system hasn't
// been configured yet (that's one of the things we're about to do).
std::cout << "Initializing spark_lib\n";
std::cout << "Configuring thread 'main'" << std::endl;
threading::configure_current_thread("main");
std::cout << "Starting default logging thread" << std::endl;
log::start_default_logging_thread();
std::cout << "Initializing LoggingConfigPoller" << std::endl;
poller = new log::LoggingConfigPoller();
}