Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add logging #27

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading