Repository: predicador37/pyjstat

Issue:
Problem with pyjstat.py logger
Hi,

In pyjstat.py there is a logging.basicConfig(level=logging.INFO) in line 43 which is causing logger problems during importing pyjstat. It's modifying the logger instance of any projects which are importing pyjstat.

I attached a picture about the problem and also a possible workaround which is used by us, but it long term we would need a solution for this (We would need to simply remove the basicConfig row from the pyjstat file)
![pyjstat_logger](https://user-images.githubusercontent.com/49643539/114891820-81d5ca00-9e0c-11eb-84ea-9c9236e9f5fd.png)
![workaround](https://user-images.githubusercontent.com/49643539/114891976-a467e300-9e0c-11eb-880d-2dbf99367f76.png)



Discussion:

Patch:
diff --git a/pyjstat/pyjstat.py b/pyjstat/pyjstat.py
index ccd0f17..89f0925 100644
--- a/pyjstat/pyjstat.py
+++ b/pyjstat/pyjstat.py
@@ -40,8 +40,8 @@ import pandas as pd
 
 import requests
 
-logging.basicConfig(level=logging.INFO)
 LOGGER = logging.getLogger(__name__)
+LOGGER.setLevel(logging.INFO)
 
 try:
     basestring


Test patch:
diff --git a/pyjstat/test/test_import.py b/pyjstat/test/test_import.py
new file mode 100644
index 0000000..f9bafc4
--- /dev/null
+++ b/pyjstat/test/test_import.py
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+"""Unit tests for logging import from pyjstat."""
+
+# Dependencies
+import logging
+import unittest
+
+# Class to be tested
+from pyjstat import pyjstat
+
+
+class TestPyjstat(unittest.TestCase):
+    """Unit tests for logging import from pyjstat."""
+
+    def setUp(self):
+        """
+        Set up test environment.
+
+        Remove all handlers associated with the root logger object
+        and set default log level.
+        """
+        for handler in logging.root.handlers[:]:
+            logging.root.removeHandler(handler)
+
+        logging.basicConfig(level=logging.ERROR)
+
+    def test_import(self):
+        """Check log level for root and child logger instances."""
+        self.assertEqual(
+            logging.getLogger('pyjstat.pyjstat').getEffectiveLevel(),
+            logging.INFO
+            )
+        self.assertEqual(
+            logging.getLogger().getEffectiveLevel(),
+            logging.ERROR)