diff --git a/Makefile b/Makefile index ee84fbf..f123daf 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,10 @@ all: fetch html fetch: /bin/php php/fetch-servers.php +# Fetch room listing with extra verbosity. +fetch-v: + /bin/php php/fetch-servers.php --verbose + # Generate HTML from data. html: /bin/php php/generate-html.php diff --git a/php/fetch-servers.php b/php/fetch-servers.php index 4d368c5..8d07227 100644 --- a/php/fetch-servers.php +++ b/php/fetch-servers.php @@ -8,10 +8,16 @@ require_once 'utils/servers-rooms.php'; function main() { + global $LOGGING_VERBOSITY; // Get join links -> Add known servers -> // De-dupe based on base URL -> // Test domains -> De-dupe based on pubkey + $options = getopt("v", ["verbose"]); + if (isset($options["v"]) or isset($options["verbose"])) { + $LOGGING_VERBOSITY = LoggingVerbosity::Debug; + } + global $CACHE_ROOT, $ROOMS_FILE, $KNOWN_SERVERS, $KNOWN_PUBKEYS; file_exists($CACHE_ROOT) or mkdir($CACHE_ROOT, 0700); diff --git a/php/utils/logging.php b/php/utils/logging.php index ef6019e..82309d1 100644 --- a/php/utils/logging.php +++ b/php/utils/logging.php @@ -40,14 +40,12 @@ return match($verbosity) { LoggingVerbosity::Error => "\033[31m", LoggingVerbosity::Warning => "\033[93m", - // LoggingVerbosity::Debug => "\033[90m", + LoggingVerbosity::Debug => "\033[90m", default => '' }; } } - $VERBOSITY = LoggingVerbosity::Info; - /** * Calculate process runtime as [s, ns]. * @return int[] Seconds and nanoseconds. @@ -73,8 +71,8 @@ } function _log_message(string $msg, int $message_verbosity) { - global $VERBOSITY; - if ($message_verbosity > $VERBOSITY) return; + global $LOGGING_VERBOSITY; + if ($message_verbosity > $LOGGING_VERBOSITY) return; $runtime = runtime_str(); $marker = LoggingVerbosity::getVerbosityMarker($message_verbosity); $color_marker = LoggingVerbosity::getVerbosityColorMarker($message_verbosity); @@ -102,4 +100,6 @@ function log_value(mixed $value) { log_debug(var_export($value, true)); } + + $LOGGING_VERBOSITY = LoggingVerbosity::Info; ?>