Skip to content

Commit

Permalink
Add logging module
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Leclercq authored and ggreg committed Aug 31, 2017
1 parent 64c616a commit 063b2bd
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 9 deletions.
4 changes: 2 additions & 2 deletions integration_tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from __future__ import print_function

from contextlib import closing
import logging
import os
import requests
import socket
Expand All @@ -28,9 +27,10 @@

from prestodb.client import PrestoQuery, PrestoRequest
from prestodb.constants import DEFAULT_PORT
import prestodb.logging


logger = logging.getLogger(__name__)
logger = prestodb.logging.get_logger(__name__)


def get_latest_release():
Expand Down
1 change: 1 addition & 0 deletions prestodb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
from . import dbapi
from . import client
from . import constants
from . import logging

__version__ = '0.3.0'
5 changes: 2 additions & 3 deletions prestodb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from __future__ import division
from __future__ import print_function

import logging
import os
from requests_kerberos.exceptions import KerberosExchangeError
from typing import Any, Dict, List, Optional, Text, Tuple, Union # NOQA for mypy types
Expand All @@ -45,14 +44,14 @@

from prestodb import constants
from prestodb import exceptions
import prestodb.logging
import prestodb.redirect


__all__ = ['PrestoQuery', 'PrestoRequest']


logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
logger = prestodb.logging.get_logger(__name__)


MAX_ATTEMPTS = constants.DEFAULT_MAX_ATTEMPTS
Expand Down
4 changes: 2 additions & 2 deletions prestodb/dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@

from future.standard_library import install_aliases
install_aliases()
import logging

from typing import Any, List, Optional # NOQA for mypy types

from prestodb import constants
import prestodb.exceptions
import prestodb.client
import prestodb.logging
import prestodb.redirect


Expand All @@ -39,7 +39,7 @@
apilevel = '2.0'
threadsafety = 2

logger = logging.getLogger(__name__)
logger = prestodb.logging.get_logger(__name__)


class Error(Exception):
Expand Down
4 changes: 2 additions & 2 deletions prestodb/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
from __future__ import print_function

import functools
import logging
import random
import time

import prestodb.logging

logger = logging.getLogger(__name__)
logger = prestodb.logging.get_logger(__name__)


class HttpError(Exception):
Expand Down
25 changes: 25 additions & 0 deletions prestodb/logging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import logging

LEVEL = logging.INFO


# TODO: provide interface to use ``logging.dictConfig``
def get_logger(name, log_level=LEVEL):
logger = logging.getLogger(name)
logger.setLevel(log_level)
return logger

0 comments on commit 063b2bd

Please sign in to comment.