Logging
Nexar uses Python's standard logging module under the "nexar" logger name. All API calls, rate limit events, cache operations, and errors are logged, giving you visibility into the client's behavior.
Basic Logging
Enable INFO-level logging to see API calls and statistics:
# Enable logging for nexar
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("nexar")
logger.setLevel(logging.INFO)
client = NexarClient(
riot_api_key=api_key,
default_region=Region.NA1,
)
async with client:
account = await client.get_riot_account("bexli", "bex")
Example Output
API Call #1: /riot/account/v1/accounts/by-riot-id/bexli/bex (region: na1)
Success (Status: 200, fresh)
Verbose Logging
Enable DEBUG-level logging for detailed output including rate limiter decisions and cache hits:
# Enable debug-level logging for detailed output
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s [%(name)s] %(levelname)s: %(message)s",
)
logger = logging.getLogger("nexar")
logger.setLevel(logging.DEBUG)
client = NexarClient(
riot_api_key=api_key,
default_region=Region.NA1,
)
async with client:
account = await client.get_riot_account("bexli", "bex")
Example Output
2026-05-16 12:00:00,123 [nexar] INFO: API Call #1: /riot/account/v1/accounts/by-riot-id/bexli/bex (region: na1)
2026-05-16 12:00:00,456 [nexar] INFO: Success (Status: 200, from cache)
Suppress Logging
To silence nexar logging entirely:
# Suppress nexar logging entirely
logger = logging.getLogger("nexar")
logger.setLevel(logging.CRITICAL + 1)
client = NexarClient(
riot_api_key=api_key,
default_region=Region.NA1,
)
async with client:
account = await client.get_riot_account("bexli", "bex")
Custom Log Handler
Route nexar logs to a file or integrate with your application's logging setup:
# Route nexar logs to a file
logger = logging.getLogger("nexar")
logger.setLevel(logging.DEBUG)
file_handler = logging.FileHandler("nexar.log")
file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(logging.Formatter("%(asctime)s [%(name)s] %(levelname)s: %(message)s"))
logger.addHandler(file_handler)
client = NexarClient(
riot_api_key=api_key,
default_region=Region.NA1,
)
async with client:
account = await client.get_riot_account("bexli", "bex")
Log Levels
The "nexar" logger emits messages at the following levels:
| Level | Used For |
|---|---|
DEBUG |
Rate limiter decisions, method ID extraction, cache internals |
INFO |
API calls, response status, cache management, call stats |
WARNING |
Transient request retries (network errors, timeouts) |
ERROR |
Non-retryable request failures and API exceptions |