Skip to content

Commit

Permalink
Merge pull request #161 from DataDog/yann/logging-null-handler
Browse files Browse the repository at this point in the history
[logging] rename loggers and set handlers to null
  • Loading branch information
yannmh authored Sep 21, 2016
2 parents 01a702e + 8f5f29c commit 7e47fae
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 22 deletions.
6 changes: 6 additions & 0 deletions datadog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* datadog.dogshell: a command-line tool, wrapping datadog.api, to interact with Datadog REST API.
"""
# stdlib
import logging
import os
import os.path

Expand All @@ -22,6 +23,11 @@

__version__ = get_version()

# Loggers
logging.getLogger('datadog.api').addHandler(logging.NullHandler())
logging.getLogger('datadog.dogstatsd').addHandler(logging.NullHandler())
logging.getLogger('datadog.threadstats').addHandler(logging.NullHandler())


def initialize(api_key=None, app_key=None, host_name=None, api_host=None,
statsd_host=None, statsd_port=None, statsd_use_default_route=False, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion datadog/api/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from datadog.util.compat import json, is_p3k


log = logging.getLogger('dd.datadogpy')
log = logging.getLogger('datadog.api')


class APIClient(object):
Expand Down
2 changes: 1 addition & 1 deletion datadog/api/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from datadog.api.exceptions import ClientError, HTTPError, HttpTimeout


log = logging.getLogger('dd.datadogpy')
log = logging.getLogger('datadog.api')


class HTTPClient(object):
Expand Down
6 changes: 0 additions & 6 deletions datadog/api/resources.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
"""
Datadog API resources.
"""
# stdlib
import logging

# datadog
from datadog.api.api_client import APIClient


log = logging.getLogger('dd.datadogpy')


class CreateableAPIResource(object):
"""
Creatable API Resource
Expand Down
5 changes: 0 additions & 5 deletions datadog/dogshell/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# stdlib
import logging
import os

# 3p
Expand All @@ -21,11 +20,8 @@
from datadog.dogshell.timeboard import TimeboardClient
from datadog.util.config import get_version

logging.getLogger('dd.datadogpy').setLevel(logging.CRITICAL)


def main():

parser = argparse.ArgumentParser(description="Interact with the Datadog API",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--config', help="location of your dogrc file (default ~/.dogrc)",
Expand All @@ -49,7 +45,6 @@ def main():
config = DogshellConfig()

# Set up subparsers for each service

subparsers = parser.add_subparsers(title='Modes', dest='mode')
subparsers.required = True

Expand Down
3 changes: 0 additions & 3 deletions datadog/dogshell/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
from __future__ import print_function
import os
import sys
import logging

# datadog
from datadog.util.compat import is_p3k, configparser, IterableUserDict,\
get_input

log = logging.getLogger('dd.datadogpy')


def print_err(msg):
if is_p3k():
Expand Down
3 changes: 2 additions & 1 deletion datadog/dogstatsd/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from datadog.util.compat import text


log = logging.getLogger('dogstatsd')
# Logging
log = logging.getLogger('datadog.dogstatsd')


class DogStatsd(object):
Expand Down
2 changes: 1 addition & 1 deletion datadog/threadstats/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from datadog.threadstats.reporters import HttpReporter

# Loggers
log = logging.getLogger('dd.datadogpy')
log = logging.getLogger('datadog.threadstats')


class ThreadStats(object):
Expand Down
3 changes: 0 additions & 3 deletions datadog/util/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import logging
import string
import sys

Expand All @@ -9,8 +8,6 @@
# CONSTANTS
DATADOG_CONF = "datadog.conf"

log = logging.getLogger('dd.datadogpy')


class CfgNotFound(Exception):
pass
Expand Down
2 changes: 1 addition & 1 deletion datadog/util/hostname.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
VALID_HOSTNAME_RFC_1123_PATTERN = re.compile(r"^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$") # noqa
MAX_HOSTNAME_LEN = 255

log = logging.getLogger('dd.datadogpy')
log = logging.getLogger('datadog.api')


def is_valid_hostname(hostname):
Expand Down

0 comments on commit 7e47fae

Please sign in to comment.