# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
+import logging
import json
+import sys
+
+logging.basicConfig(level=logging.INFO)
+logger = logging.getLogger(__name__)
with open("config.json") as f:
- # DEBUG: print("DEBUG: Loading configuration file ...")
+ logger.debug("Loading configuration file ...")
_config = json.loads(f.read())
+ _config["max_crawl_depth"] = min(_config["max_crawl_depth"], (sys.getrecursionlimit() - 50))
+ logger.debug("LOADED!")
def get(key: str) -> any:
- # DEBUG: print(f"DEBUG: key[{type(key)}]={key} - CALLED!")
+ logger.debug("key[%s]='%s' - CALLED!", type(key), key)
+
if not isinstance(key, str):
- raise ValueError(f"Parameter key[]='{type(key)}' is not 'str'")
+ raise ValueError(f"Parameter key[]='{type(key)}' is not of type 'str'")
elif key == "":
raise ValueError("Parameter 'key' is empty")
elif not key in _config:
raise KeyError(f"key='{key}' does not exist in _config array")
- # DEBUG: print(f"DEBUG: _config[{key}]={_config[key]} - EXIT!")
+ logger.debug("_config[%s][%s]='%s' - EXIT!", key, type(_config[key]), _config[key] if not key.endswith("_api_key") else "***")
return _config[key]