Skip to content

Commit

Permalink
Merge pull request #5 from nrccua/ARCH-476-set-logger-propogate-to-fa…
Browse files Browse the repository at this point in the history
…lse-and-remove-redundant

Improving DatadogLogger
  • Loading branch information
nrccua-timr authored Nov 17, 2020
2 parents ba876ba + 8974889 commit 50e11bf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
7 changes: 7 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ History
=======


v0.9.0 (2020-11-17)
-----------------------

* Set logger.propogate to False after adding handler.
* Remove use_ddtrace logic from DatadogLogger.


v0.8.5 (2020-11-11)
-----------------------

Expand Down
15 changes: 2 additions & 13 deletions aioradio/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@
for cleaner datadog logging.'''

# pylint: disable=too-few-public-methods
# pylint: disable=too-many-arguments
# pylint: disable=too-many-instance-attributes

import logging
import os
import sys
from datetime import datetime
from typing import List

from ddtrace import tracer
from pythonjsonlogger import jsonlogger


Expand Down Expand Up @@ -45,22 +41,14 @@ def __init__(
main_logger='',
datadog_loggers=List[str],
log_level=logging.INFO,
log_format="%(timestamp)d %(level)d %(name)d %(message)d",
use_ddtrace=True
log_format="%(timestamp)d %(level)d %(name)d %(message)d"
):

self.logger = logging.getLogger(main_logger)
self.logger.setLevel(log_level)
self.log_level = log_level
self.datadog_loggers = set(datadog_loggers) if datadog_loggers else []
self.format = log_format

if use_ddtrace:
tracer.configure(
hostname=os.getenv('DD_AGENT_HOST', ''),
port=os.getenv('DD_TRACE_AGENT_PORT', '')
)

self.add_handlers()

def add_handlers(self):
Expand All @@ -73,3 +61,4 @@ def add_handlers(self):
handler.setLevel(self.log_level)
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.propagate = False
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
long_description = fileobj.read()

setup(name='aioradio',
version='0.8.5',
version='0.9.0',
description='Generic asynchronous i/o python utilities for AWS services (SQS, S3, DynamoDB, Secrets Manager), Redis, MSSQL (pyodbc), JIRA and more',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 50e11bf

Please sign in to comment.