CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
cdc_log.h File Reference

CDC Log: logging over TinyUSB CDC and UART. More...

#include <stdio.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>

Go to the source code of this file.

Classes

struct  cdc::log::error_log_entry_t

Namespaces

namespace  cdc
namespace  cdc::log

Macros

#define ERROR_LOG_MAX_ENTRIES   50
#define ERROR_LOG_LINE_LEN   100
#define LOG_E(tag, fmt, ...)
#define LOG_W(tag, fmt, ...)
#define LOG_I(tag, fmt, ...)
#define LOG_D(tag, fmt, ...)
#define LOG_V(tag, fmt, ...)
#define LOGE(fmt, ...)
#define LOGW(fmt, ...)
#define LOGI(fmt, ...)
#define LOGD(fmt, ...)
#define LOGV(fmt, ...)

Typedefs

typedef void(* console_output_hook_t) (const char *data, size_t len)
 Output hook called for every console output.
typedef bool(* console_input_available_hook_t) (void)
 Input-available hook used to check if additional input is available.
typedef int(* console_input_getchar_hook_t) (void)
 Input getchar hook used to fetch one character from an additional source.
typedef bool(* log_authgate_hook_t) (void)
 Hook polled before INFO/DEBUG/VERBOSE log lines reach the console.

Enumerations

enum  cdc::log::log_level_t {
  cdc::log::CDC_LOG_LEVEL_NONE = 0 , cdc::log::CDC_LOG_LEVEL_ERROR , cdc::log::CDC_LOG_LEVEL_WARN , cdc::log::CDC_LOG_LEVEL_INFO ,
  cdc::log::CDC_LOG_LEVEL_DEBUG , cdc::log::CDC_LOG_LEVEL_VERBOSE
}

Functions

size_t error_log_get_entries (error_log_entry_t *entries, size_t max_entries)
 Copies stored error-log entries in chronological order.
size_t error_log_get_count (void)
 Returns number of buffered error-log entries.
void error_log_clear (void)
 Clears error-log ring buffer state.
void error_log_dump (void)
 Dumps buffered error-log entries to console.
void log_init (void)
 Logging API implementation.
void log_set_level (log_level_t level)
 Sets runtime log verbosity threshold.
log_level_t log_get_level (void)
 Returns current log verbosity threshold.
void log_write (log_level_t level, const char *tag, const char *fmt,...)
 Writes formatted tagged log line with optional suppression.
void log_raw (const char *fmt,...)
 Writes untagged raw formatted text to console.
void log_hex (const char *tag, const char *label, const uint8_t *data, size_t len)
 Logs binary buffer as grouped hexadecimal bytes.
void console_init (void)
 Initializes console I/O transport state.
bool console_available (void)
 Returns whether any console input source has pending data.
int console_getchar (void)
 Reads one character from available console input source.
void console_print (const char *str)
 Writes string to active console outputs.
void console_printf (const char *fmt,...)
 Formatted write helper for console output.
void console_putchar (char c)
 Writes single character to active console outputs.
void console_flush (void)
 Flushes buffered console output transports.
void console_register_output_hook (console_output_hook_t hook)
 Registers the console output hook (only one supported at a time).
void console_register_input_hook (console_input_available_hook_t avail_hook, console_input_getchar_hook_t getchar_hook)
 Registers the console input hooks (only one set supported at a time).
void log_register_authgate_hook (log_authgate_hook_t hook)
 Registers (or clears) the auth-gate hook for INFO/DEBUG/VERBOSE.

Detailed Description

CDC Log: logging over TinyUSB CDC and UART.

Logging system that outputs to both USB CDC and UART. Includes error log (PSRAM-backed ring buffer for ERROR/WARN).

Definition in file cdc_log.h.

Macro Definition Documentation

◆ ERROR_LOG_LINE_LEN

#define ERROR_LOG_LINE_LEN   100

Definition at line 38 of file cdc_log.h.

Referenced by error_log_add().

◆ ERROR_LOG_MAX_ENTRIES

#define ERROR_LOG_MAX_ENTRIES   50

Definition at line 37 of file cdc_log.h.

Referenced by error_log_add(), error_log_dump(), and error_log_get_entries().

◆ LOG_D

#define LOG_D ( tag,
fmt,
... )
Value:
log_write(CDC_LOG_LEVEL_DEBUG, tag, fmt, ##__VA_ARGS__)
void log_write(log_level_t level, const char *tag, const char *fmt,...)
Writes formatted tagged log line with optional suppression.
Definition cdc_log.cpp:171

Definition at line 148 of file cdc_log.h.

Referenced by cdc::ui::ViewStack::acquireExclusive(), client_pin_compute_shared_secret(), client_pin_get_pin_token(), cdc::mod_fido2::create_credential_and_respond(), ctap2_cancel(), ctaphid_process_packet(), cdc::hal::Esp32SleepController::enterLightSleep(), fido2_storage_create_credential(), fido2_storage_find_by_rp_resident(), fido2_storage_find_by_rp_user(), fido2_storage_init(), fido2_storage_sign(), fido2_storage_sign_der(), fido2_storage_sign_raw(), fido2_task(), cdc::ui::T9InputView::forceDigit(), ga_verify_pin_auth(), handle_cancel(), handle_cbor(), handle_init(), handle_ping(), handle_wink(), handleWakeupAndReleaseRtcGpio(), host_log(), cdc::ui::ContextMenuView::init(), cdc::ui::InfoView::init(), cdc::ui::ListView::init(), cdc::ui::MessageBox::init(), cdc::ui::QRCodeView::init(), cdc::ui::T9InputView::init(), cdc::ui::MessageBox::onKey(), cdc::ui::MessageBox::onTick(), openpgp_process_apdu(), cdc::hal::persistBacklight(), cdc::hal::TCA9535Keypad::prepareForSleep(), cdc::hal::Esp32SleepController::prepareGpioForSleep(), process_complete_message(), cdc::ui::qrDisplayCallback(), cdc::hal::TCA9535Keypad::recoverFromSleep(), cdc::ui::ViewStack::releaseExclusive(), cdc::ui::ViewStack::replace(), sao_parse_descriptor(), sao_scan(), cdc::ui::ViewStack::setInactivityTimeout(), cdc::ui::ViewStack::showModal(), cdc::hal::Esp32SleepController::stabilizeGpioAfterWakeup(), cdc::core::EventBus::subscribe(), u2f_register(), cdc::core::EventBus::unsubscribe(), and cdc::mod_fido2::verify_pin_uv_auth().

◆ LOG_E

#define LOG_E ( tag,
fmt,
... )
Value:
log_write(CDC_LOG_LEVEL_ERROR, tag, fmt, ##__VA_ARGS__)

Definition at line 145 of file cdc_log.h.

Referenced by cdc::mod_2fa::OathStore::addAccount(), cdc::hal::I2cBusImpl::addDevice(), cdc::mod_password::PasswordStore::addEntry(), cdc::mod_2fa::ble_chalresp_init(), ccid_init(), ccid_process_message(), cdc::core::TropicStorage::cleanup(), client_pin_compute_shared_secret(), client_pin_get_pin_token(), client_pin_get_pin_uv_auth_token(), client_pin_init_ecdh(), cmd_internal_authenticate(), cmd_pso_cds(), cdc::hal::WifiController::connect(), cdc::mod_fido2::create_credential_and_respond(), ctap2_get_assertion(), ctap2_get_next_assertion(), ctaphid_init(), cdc::hal::WifiController::enable(), cdc::hal::BQ25895Power::enterShipMode(), cdc::os_ui::BackupManager::exportTo(), fido2_init(), fido2_storage_counter_increment(), fido2_storage_create_credential(), fido2_storage_get_cred_id(), fido2_storage_increment_sign_count(), fido2_storage_init(), fido2_storage_sign(), fido2_storage_sign_der(), fido2_storage_sign_raw(), ga_sign_assertion(), generate_hardware_key(), cdc::mod_2fa::OathStore::generateCode(), cdc::hal::WifiController::getScanResults(), gpg_generate_key(), host_http_perform(), host_log(), cdc::os_ui::BackupManager::importFrom(), cdc::core::EventBus::init(), cdc::hal::BQ25895Power::init(), cdc::hal::EpaperDisplay::init(), cdc::hal::I2cBusImpl::init(), cdc::hal::TCA9535Keypad::init(), cdc::hal::Tropic01Element::init(), cdc::hal::WifiController::init(), cdc::mod_ble_serial::BleUartService::init(), cdc::mod_fido2::Fido2Module::init(), cdc::plugin_manager::PluginManager::init(), cdc::core::ModuleRegistry::initAll(), cdc::core::ServiceRegistry::initAll(), initBluetoothController(), initDisplay(), initI2cBus(), initKeypad(), initPowerManager(), initSecureElement(), cdc::hal::initSharedSpiBus(), initSleepController(), initWifiController(), lockdownShutdownHandler(), lt_port_spi_transfer(), makeClient(), cdc::plugin_manager::PluginStorage::mount(), openpgp_init(), openpgp_process_apdu(), openpgp_set_key_fingerprint(), cdc::plugin_manager::PluginManifest::parse(), plg_log_error(), prepare_response(), prepare_response_on(), cdc::serial::printNvsValue(), read_byte(), read_type_value(), cdc::core::TropicStorage::rebuildVerbose(), cdc::mod_2fa::registerGattService(), cdc::core::ModuleRegistry::registerInitializer(), cdc::core::ModuleRegistry::registerModule(), cdc::core::ServiceRegistry::registerService(), cdc::ui::PinEntryView::render(), cdc::core::ModuleRegistry::reportModuleError(), cdc::core::ModuleRegistry::runAllInitializers(), sao_init(), save_slot_encrypted(), save_state_to_nvs(), se_ecc_key_generate(), cdc::core::PinManager::setBadgePin(), cdc::core::PinManager::setDuressPin(), cdc::core::PinManager::setPW1(), cdc::core::PinManager::setPW3(), cdc::hal::Tropic01Element::sleep(), cdc::core::ServiceRegistry::startAll(), cdc::hal::WifiController::startAp(), cdc::core::ModuleRegistry::startModule(), cdc::plugin_manager::PluginManager::startPlugin(), cdc::hal::WifiController::startScan(), cdc::core::EventBus::subscribe(), cdc::core::SystemLock::triggerLockdown(), u2f_attest_sign(), u2f_authenticate(), u2f_init_attestation(), u2f_register(), cdc::mod_2fa::OathStore::updateAccount(), cdc::mod_password::PasswordStore::updateEntry(), usb_cdc_init(), usb_start_stack(), cdc::core::wipeNvs(), cdc::core::wipeTropic(), wipeTropicForFactoryReset(), write_byte(), write_bytes(), write_rmem_credential(), and cdc::mod_2fa::writePayload().

◆ LOG_I

#define LOG_I ( tag,
fmt,
... )
Value:
log_write(CDC_LOG_LEVEL_INFO, tag, fmt, ##__VA_ARGS__)

Definition at line 147 of file cdc_log.h.

Referenced by cdc::hal::I2cBusImpl::addDevice(), cdc::ui::SleepManager::addSleepInhibitor(), apply_put_data_desc(), cdc::serial::SerialCmd::authenticate(), cdc::hal::EpaperDisplay::backlightOff(), cdc::hal::EpaperDisplay::backlightOn(), cdc::mod_2fa::ble_chalresp_init(), cdc::mod_gpg::ble_gpg_xsig_init(), cdc::ui::bleResolveBeginNext(), cdc::ui::bleResolveStart(), cdc::ui::bleResolveTick(), ccid_init(), ccid_process_message(), cdc::core::PinManager::checkAndResetExpiredLockout(), cdc::ui::ViewStack::checkInactivity(), cdc::core::PinManager::clearDuressPin(), client_pin_compute_shared_secret(), client_pin_get_key_agreement(), client_pin_get_pin_token(), client_pin_get_pin_uv_auth_token(), client_pin_init_ecdh(), cmd_change_reference_data(), cmd_generate_keypair(), cmd_pso_cds(), cmd_put_data(), cmd_reset_retry_counter(), cmd_select(), cmd_verify(), cdc::hal::WifiController::connect(), cdc::mod_fido2::create_credential_and_respond(), ctap2_build_auth_data_for_cred(), ctap2_client_pin(), ctap2_cred_management(), ctap2_get_assertion(), ctap2_init(), cdc::mod_fido2::ctap2_make_credential(), ctap2_process_command(), ctap2_reset(), ctaphid_init(), cdc::mod_ble_serial::BleUartService::deinit(), cdc::mod_nvsedit::deleteKey(), cdc::mod_nvsedit::deleteNamespace(), cdc::mod_2fa::deliverConfirmedResponse(), cdc::hal::WifiController::disable(), cdc::hal::WifiController::enable(), cdc::hal::Esp32SleepController::enterDeepSleep(), cdc::hal::Esp32SleepController::enterLightSleep(), cdc::hal::BQ25895Power::enterShipMode(), cdc::os_ui::BackupManager::exportTo(), fido2_factory_reset(), fido2_init(), fido2_set_pin_verified(), fido2_storage_counter_load(), fido2_storage_create_credential(), fido2_storage_delete_credential(), fido2_storage_init(), fido2_task(), cdc::mod_fido2::fido2_ui_user_presence_callback(), ga_find_credentials(), ga_verify_pin_auth(), generate_hardware_key(), gpg_generate_key(), gpg_storage_save_aes_key(), gpg_storage_save_dec_privkey(), cdc::mod_fido2::handle_browser_probe(), handle_cbor(), host_http_perform(), host_log(), host_log_hex(), cdc::os_ui::BackupManager::importFrom(), cdc::os_ui::SystemSettingsBackup::importSystemSettings(), cdc::core::EventBus::init(), cdc::core::PinManager::init(), cdc::hal::BQ25895Power::init(), cdc::hal::EpaperDisplay::init(), cdc::hal::Esp32Rtc::init(), cdc::hal::Esp32SleepController::init(), cdc::hal::I2cBusImpl::init(), cdc::hal::TCA9535Keypad::init(), cdc::hal::Tropic01Element::init(), cdc::hal::WifiController::init(), cdc::mod_2fa::TwoFaModule::init(), cdc::mod_ble_serial::BleSerialModule::init(), cdc::mod_ble_serial::BleUartService::init(), cdc::mod_fido2::Fido2Module::init(), cdc::mod_gpg::GpgModule::init(), cdc::mod_nvsedit::NvsEditModule::init(), cdc::mod_password::PasswordModule::init(), cdc::mod_sao::SaoModule::init(), cdc::mod_vcard::VcardModule::init(), cdc::plugin_manager::PluginManager::init(), cdc::serial::SerialCmd::init(), cdc::ui::I18n::init(), init_aid_from_mac(), cdc::core::ServiceRegistry::initAll(), initBluetoothController(), initCoreServices(), initDisplay(), initI2cBus(), initKeypad(), initMessageTransfer(), initModules(), initPowerManager(), initSecureElement(), initSerialCommandInterface(), cdc::hal::initSharedSpiBus(), initSleepController(), initTropicStorage(), initUi(), initWifiController(), is_dummy_application(), cdc::serial::SerialCmd::isAuthenticated(), cdc::mod_nvsedit::loadKeys(), cdc::mod_nvsedit::loadNamespaces(), cdc::ui::I18n::loadOverlay(), cdc::serial::SerialCmd::logout(), lt_port_init(), cdc::plugin_manager::PluginStorage::mount(), cdc::mod_ble_serial::BleUartService::onConnectionChange(), cdc::hal::WifiController::onIpEvent(), cdc::ui::DateInputView::onKey(), cdc::ui::TimeInputView::onKey(), cdc::core::AttestationKeyService::onTick(), cdc::hal::WifiController::onWifiEvent(), openpgp_init(), openpgp_set_key_fingerprint(), cdc::mod_fido2::parse_extensions_map(), plg_log_info(), prepare_response(), put_data_algo_attr(), read_public_key(), cdc::serial::CommandRegistry::registerCommand(), cdc::mod_2fa::registerGattService(), cdc::plugin_manager::registerGpioSerialCommands(), cdc::core::UsbManager::registerInterface(), cdc::core::ModuleRegistry::registerModule(), cdc::plugin_manager::registerPluginSerialCommands(), cdc::core::ServiceRegistry::registerService(), cdc::plugin_manager::PluginManager::reloadBackgroundPlugin(), cdc::ui::SleepManager::removeSleepInhibitor(), cdc::core::ModuleRegistry::retryModule(), cdc::core::ModuleRegistry::runAllInitializers(), runMainLoopIteration(), sao_init(), sao_scan(), cdc::hal::Tropic01Element::sessionEnd(), cdc::core::PinManager::setBadgePin(), cdc::hal::BQ25895Power::setChargingEnabled(), cdc::hal::Esp32Rtc::setDate(), cdc::core::PinManager::setDuressPin(), cdc::ui::I18n::setLanguageCode(), cdc::hal::Esp32SleepController::setLightSleepInterval(), cdc::core::PinManager::setPW1(), cdc::core::PinManager::setPW3(), cdc::hal::Esp32Rtc::setTime(), cdc::hal::Esp32Rtc::setTimestamp(), cdc::hal::Esp32Rtc::setTimezoneOffset(), cdc::hal::EpaperDisplay::showSplash(), cdc::hal::Tropic01Element::sleep(), cdc::core::AttestationKeyService::start(), cdc::mod_ble_serial::BleSerialModule::start(), cdc::mod_fido2::Fido2Module::start(), cdc::core::ModuleRegistry::startAll(), cdc::core::ServiceRegistry::startAll(), cdc::hal::WifiController::startAp(), startApp(), cdc::ui::startBluetoothScan(), cdc::core::PinManager::startLockout(), cdc::plugin_manager::PluginManager::startPlugin(), cdc::hal::WifiController::startScan(), cdc::plugin_manager::PluginManager::stopActivePlugin(), cdc::core::ServiceRegistry::stopAll(), u2f_authenticate(), u2f_init_attestation(), u2f_process_apdu(), u2f_register(), u2f_version(), cdc::plugin_manager::PluginManager::unloadAllFromRam(), cdc::plugin_manager::PluginManager::unloadFromRam(), cdc::hal::Esp32SleepController::unregisterCallbacks(), cdc::core::UsbManager::unregisterInterface(), cdc::core::ModuleRegistry::unregisterModule(), usb_cdc_init(), usb_cdc_start(), vcard_store_set_own(), cdc::mod_fido2::verify_pin_uv_auth(), and wait_for_user_presence().

◆ LOG_V

#define LOG_V ( tag,
fmt,
... )
Value:
log_write(CDC_LOG_LEVEL_VERBOSE, tag, fmt, ##__VA_ARGS__)

Definition at line 149 of file cdc_log.h.

Referenced by host_log().

◆ LOG_W

#define LOG_W ( tag,
fmt,
... )
Value:
log_write(CDC_LOG_LEVEL_WARN, tag, fmt, ##__VA_ARGS__)

Definition at line 146 of file cdc_log.h.

Referenced by cdc::ui::ViewStack::acquireExclusive(), cdc::plugin_manager::PluginManager::activateForMessageType(), cdc::mod_2fa::OathStore::addAccount(), cdc::mod_password::PasswordStore::addEntry(), cdc::mod_gpg::GpgRecvStore::addKey(), cdc::ui::SleepManager::addSleepInhibitor(), alloc_channel(), apply_response_chaining(), cdc::serial::SerialCmd::authenticate(), cdc::mod_2fa::ble_chalresp_tick(), cdc::mod_gpg::ble_gpg_xsig_init(), cdc::ui::bleResolveBeginNext(), cdc::ui::bleResolveStart(), cdc::ui::bleResolveTick(), build_config_descriptor(), cbor_skip_item_impl(), ccid_process_message(), cdc::mod_2fa::OathStore::challengeResponse(), cdc::core::TropicStorage::cleanup(), client_pin_get_pin_token(), client_pin_get_pin_uv_auth_token(), cmd_activate_file(), cmd_generate_keypair(), cmd_get_data(), cmd_put_data(), cmd_terminate_df(), cmd_verify(), cdc::hal::WifiController::connect(), cred_mgmt_slot_has_key(), ctap2_client_pin(), ctaphid_check_timeout(), ctaphid_get_response_packet(), ctaphid_process_packet(), ctaphid_send_error(), cdc::mod_vcard::deliverVcard(), cdc::ui::CanvasView::drawText(), cdc::ui::CanvasView::drawTextAligned(), cdc::hal::BluetoothControllerStub::enable(), fido2_factory_reset(), fido2_init(), fido2_request_user_presence(), fido2_storage_counter_load(), fido2_task(), cdc::mod_fido2::fido2_ui_abort_prompt(), cdc::mod_fido2::fido2_ui_user_presence_callback(), ga_verify_pin_auth(), cdc::hal::Tropic01Element::getRandom(), cdc::hal::EspHardware::getTemperatureC(), gpg_export_pubkey_pem(), cdc::mod_gpg::gpgCrossSign(), host_http_perform(), host_i18n_tr_meta(), host_log(), host_socket_open(), cdc::mod_2fa::TwoFaModule::importBackup(), cdc::mod_password::PasswordModule::importBackup(), cdc::mod_vcard::VcardModule::importBackup(), cdc::os_ui::BackupManager::importFrom(), cdc::mod_2fa::importOathEntry(), cdc::mod_password::importPasswordEntry(), cdc::os_ui::SystemSettingsBackup::importSystemSettings(), cdc::core::EventBus::init(), cdc::core::TropicStorage::init(), cdc::hal::BluetoothControllerStub::init(), cdc::hal::Esp32Rtc::init(), cdc::hal::Esp32SleepController::init(), cdc::hal::EspHardware::init(), cdc::hal::SecureElementStub::init(), cdc::mod_2fa::TwoFaModule::init(), init_aid_from_mac(), initPluginSystem(), initRtc(), initSecureElement(), cdc::plugin_manager::PluginStorage::listPluginIds(), load_state_from_nvs(), cdc::mod_2fa::onChallengeWrite(), cdc::mod_fido2::onFidoSetReport(), cdc::hal::WifiController::onIpEvent(), cdc::ui::BlePairingPromptView::onTick(), cdc::mod_2fa::onTouchCancel(), openpgp_process_apdu(), plg_gpio_on_unload(), plg_http_on_unload(), plg_log_warn(), plg_socket_on_unload(), prepare_response(), read_public_key(), cdc::mod_2fa::OathStore::readAccount(), cdc::serial::CommandRegistry::registerCommand(), cdc::core::UsbManager::registerInterface(), cdc::core::ModuleRegistry::registerModule(), cdc::ui::ViewStack::releaseExclusive(), cdc::ui::ViewStack::replace(), cdc::core::ModuleRegistry::reportModuleError(), cdc::core::ModuleRegistry::runAllInitializers(), se_ecc_key_generate(), cdc::core::ModuleRegistry::setModuleEnabled(), cdc::hal::Esp32Rtc::setTime(), cdc::hal::Esp32Rtc::setTimezoneOffset(), cdc::ui::ViewStack::showModal(), cdc::mod_fido2::Fido2Module::start(), cdc::mod_gpg::GpgModule::start(), cdc::mod_sao::SaoModule::start(), cdc::plugin_manager::PluginManager::startPlugin(), cdc::hal::WifiController::startScan(), u2f_authenticate(), u2f_process_apdu(), cdc::core::UsbManager::unregisterInterface(), cdc::hal::BQ25895Power::update(), cdc::mod_2fa::OathStore::updateAccount(), cdc::mod_2fa::validateOathParams(), cdc::core::verify_payload_signature(), cdc::mod_fido2::verify_pin_uv_auth(), wait_for_user_presence(), cdc::plugin_manager::Prerequisites::walk(), wipeTropicForFactoryReset(), and cdc::mod_vcard::wizardFinish().

◆ LOGD

#define LOGD ( fmt,
... )
Value:
LOG_D("APP", fmt, ##__VA_ARGS__)
#define LOG_D(tag, fmt,...)
Definition cdc_log.h:148

Definition at line 155 of file cdc_log.h.

◆ LOGE

#define LOGE ( fmt,
... )
Value:
LOG_E("APP", fmt, ##__VA_ARGS__)
#define LOG_E(tag, fmt,...)
Definition cdc_log.h:145

Definition at line 152 of file cdc_log.h.

◆ LOGI

#define LOGI ( fmt,
... )
Value:
LOG_I("APP", fmt, ##__VA_ARGS__)
#define LOG_I(tag, fmt,...)
Definition cdc_log.h:147

Definition at line 154 of file cdc_log.h.

◆ LOGV

#define LOGV ( fmt,
... )
Value:
LOG_V("APP", fmt, ##__VA_ARGS__)
#define LOG_V(tag, fmt,...)
Definition cdc_log.h:149

Definition at line 156 of file cdc_log.h.

◆ LOGW

#define LOGW ( fmt,
... )
Value:
LOG_W("APP", fmt, ##__VA_ARGS__)
#define LOG_W(tag, fmt,...)
Definition cdc_log.h:146

Definition at line 153 of file cdc_log.h.

Typedef Documentation

◆ console_input_available_hook_t

typedef bool(* console_input_available_hook_t) (void)

Input-available hook used to check if additional input is available.

Returns
true if data is available.

Definition at line 103 of file cdc_log.h.

◆ console_input_getchar_hook_t

typedef int(* console_input_getchar_hook_t) (void)

Input getchar hook used to fetch one character from an additional source.

Returns
Character or -1 if none available.

Definition at line 109 of file cdc_log.h.

◆ console_output_hook_t

typedef void(* console_output_hook_t) (const char *data, size_t len)

Output hook called for every console output.

Parameters
dataOutput data.
lenData length.

Definition at line 97 of file cdc_log.h.

◆ log_authgate_hook_t

typedef bool(* log_authgate_hook_t) (void)

Hook polled before INFO/DEBUG/VERBOSE log lines reach the console.

Returns
true if those levels may be emitted, false to drop the line.

ERROR/WARN are never gated. Used by SerialCmd to suppress INFO/DEBUG output until a session is authenticated.

Definition at line 132 of file cdc_log.h.

Function Documentation

◆ console_available()

bool console_available ( void )

Returns whether any console input source has pending data.

Returns
true if input is available.

Definition at line 261 of file cdc_log.cpp.

References s_initialized, and s_input_avail_hook.

Referenced by cdc::serial::Console::available().

◆ console_flush()

void console_flush ( void )

Flushes buffered console output transports.

Definition at line 393 of file cdc_log.cpp.

References s_initialized.

Referenced by cdc::hal::WifiController::enable(), cdc::serial::Console::flush(), and cdc::hal::WifiController::onWifiEvent().

◆ console_getchar()

int console_getchar ( void )

Reads one character from available console input source.

Returns
Character value or -1 when no data is available.

Definition at line 282 of file cdc_log.cpp.

References s_initialized, and s_input_getchar_hook.

Referenced by cdc::serial::Console::getchar().

◆ console_init()

void console_init ( void )

Initializes console I/O transport state.

Definition at line 245 of file cdc_log.cpp.

References flags, and s_initialized.

Referenced by log_init().

◆ console_print()

void console_print ( const char * str)

Writes string to active console outputs.

Parameters
strNull-terminated string.

Definition at line 312 of file cdc_log.cpp.

References s_initialized, and s_output_hook.

Referenced by console_printf(), log_hex(), log_raw(), and cdc::serial::Console::print().

◆ console_printf()

void console_printf ( const char * fmt,
... )

Formatted write helper for console output.

Parameters
fmtPrintf-style format string.

Definition at line 358 of file cdc_log.cpp.

References console_print().

Referenced by error_log_dump(), log_hex(), and log_write().

◆ console_putchar()

void console_putchar ( char c)

Writes single character to active console outputs.

Parameters
cCharacter to output.

Definition at line 373 of file cdc_log.cpp.

References s_initialized, and s_output_hook.

Referenced by log_hex(), and cdc::serial::Console::putchar().

◆ console_register_input_hook()

void console_register_input_hook ( console_input_available_hook_t avail_hook,
console_input_getchar_hook_t getchar_hook )

Registers the console input hooks (only one set supported at a time).

Parameters
avail_hookAvailable-check callback, or NULL to unregister.
getchar_hookGetchar callback, or NULL to unregister.

Registers the console input hooks (only one set supported at a time).

Parameters
avail_hookInput-available callback.
getchar_hookCharacter-read callback.

Definition at line 416 of file cdc_log.cpp.

References s_input_avail_hook, and s_input_getchar_hook.

◆ console_register_output_hook()

void console_register_output_hook ( console_output_hook_t hook)

Registers the console output hook (only one supported at a time).

Parameters
hookCallback function, or NULL to unregister.

Registers the console output hook (only one supported at a time).

Registers optional additional output transport hook.

Parameters
hookOutput callback.

Definition at line 407 of file cdc_log.cpp.

References s_output_hook.

◆ error_log_clear()

void error_log_clear ( void )

Clears error-log ring buffer state.

Definition at line 104 of file cdc_log.cpp.

References s_error_log_count, and s_error_log_head.

Referenced by cdc::serial::cmdErrorLog().

◆ error_log_dump()

void error_log_dump ( void )

Dumps buffered error-log entries to console.

Definition at line 112 of file cdc_log.cpp.

References console_printf(), ERROR_LOG_MAX_ENTRIES, s_error_log, s_error_log_count, and s_error_log_head.

Referenced by cdc::serial::cmdErrorLog().

◆ error_log_get_count()

size_t error_log_get_count ( void )

Returns number of buffered error-log entries.

Returns
Entry count.

Definition at line 97 of file cdc_log.cpp.

References s_error_log_count.

◆ error_log_get_entries()

size_t error_log_get_entries ( error_log_entry_t * entries,
size_t max_entries )

Copies stored error-log entries in chronological order.

Parameters
entriesOutput entry buffer.
max_entriesMaximum writable entries.
Returns
Number of copied entries.

Definition at line 79 of file cdc_log.cpp.

References ERROR_LOG_MAX_ENTRIES, s_error_log, s_error_log_count, and s_error_log_head.

◆ log_get_level()

log_level_t log_get_level ( void )

Returns current log verbosity threshold.

Returns
Active log level.

Definition at line 161 of file cdc_log.cpp.

References s_log_level.

◆ log_hex()

void log_hex ( const char * tag,
const char * label,
const uint8_t * data,
size_t len )

Logs binary buffer as grouped hexadecimal bytes.

Parameters
tagLog tag.
labelData label.
dataInput byte buffer.
lenBuffer length.

Definition at line 224 of file cdc_log.cpp.

References console_print(), console_printf(), and console_putchar().

◆ log_init()

void log_init ( void )

Logging API implementation.

Initializes logging subsystem and console backend.

Definition at line 140 of file cdc_log.cpp.

References console_init(), and s_log_level.

Referenced by initCoreServices().

◆ log_raw()

void log_raw ( const char * fmt,
... )

Writes untagged raw formatted text to console.

Parameters
fmtPrintf-style format string.

Definition at line 208 of file cdc_log.cpp.

References console_print().

◆ log_register_authgate_hook()

void log_register_authgate_hook ( log_authgate_hook_t hook)

Registers (or clears) the auth-gate hook for INFO/DEBUG/VERBOSE.

Parameters
hookCallback, or NULL to disable gating.

Registers (or clears) the auth-gate hook for INFO/DEBUG/VERBOSE.

Parameters
hookCallback returning true when the gate is open, false to drop the line. NULL disables gating.

Definition at line 428 of file cdc_log.cpp.

References s_authgate_hook.

Referenced by cdc::serial::SerialCmd::init().

◆ log_set_level()

void log_set_level ( log_level_t level)

Sets runtime log verbosity threshold.

Parameters
levelNew log level.

Definition at line 153 of file cdc_log.cpp.

References s_log_level.

Referenced by cdc::serial::SerialCmd::authenticate(), cdc::serial::SerialCmd::init(), cdc::serial::SerialCmd::isAuthenticated(), and cdc::serial::SerialCmd::logout().

◆ log_write()

void log_write ( log_level_t level,
const char * tag,
const char * fmt,
... )

Writes formatted tagged log line with optional suppression.

Parameters
levelLog level.
tagLog tag.
fmtPrintf-style format string.

Definition at line 171 of file cdc_log.cpp.

References console_printf(), error_log_add(), level_str, s_authgate_hook, and s_log_level.