Skip to content

Commit

Permalink
add logging (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
russbiggs authored Aug 28, 2024
1 parent af46152 commit ed08280
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions openaq/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
"""OpenAQ Python SDK."""

import logging


__version__ = "0.3.0"


logger = logging.getLogger("openaq")
logger.addHandler(logging.NullHandler())


from ._async.client import AsyncOpenAQ as AsyncOpenAQ
from ._sync.client import OpenAQ as OpenAQ
from .shared.exceptions import (
Expand Down
9 changes: 9 additions & 0 deletions openaq/shared/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
import os
import platform
from abc import ABC, abstractmethod
import logging
from pathlib import Path
from typing import Any, Mapping, Union

from openaq._sync.transport import Transport
from openaq._async.transport import AsyncTransport

logger = logging.getLogger('openaq')

# for Python versions <3.11 tomllib is not part of std. library
_has_toml = True
try:
Expand Down Expand Up @@ -73,6 +76,12 @@ def __init__(
self._user_agent = user_agent
self.resolve_headers()

def _check_api_key_url(self):
if not self.api_key and self.base_url == DEFAULT_BASE_URL:
logger.warning(
"API key not set: An API key is required when using the OpenAQ API"
)

def _get_api_key(self) -> str:
"""Gets API key value from env or openaq config file.
Expand Down

0 comments on commit ed08280

Please sign in to comment.