diff --git a/ee/api/chalicelib/core/unlock.py b/ee/api/chalicelib/core/unlock.py index cb38446a3f..deb7c5f798 100644 --- a/ee/api/chalicelib/core/unlock.py +++ b/ee/api/chalicelib/core/unlock.py @@ -1,3 +1,4 @@ +import logging import uuid from os import environ @@ -7,6 +8,8 @@ from chalicelib.utils import helper from chalicelib.utils.TimeUTC import TimeUTC +logger = logging.getLogger(__name__) + def __get_mid(): return str(uuid.UUID(int=uuid.getnode())) @@ -19,15 +22,16 @@ def get_license(): def check(): license = get_license() if license is None or len(license) == 0: - print("!! license key not found, please provide a LICENSE_KEY env var") + logger.warning("!! license key not found, please provide a LICENSE_KEY env var") environ["expiration"] = "-1" environ["numberOfSeats"] = "0" return - print(f"validating: {helper.obfuscate(license)}") - r = requests.post('https://api.openreplay.com/license/validate', json={"mid": __get_mid(), "license": get_license()}) + logger.info(f"validating: {helper.obfuscate(license)}") + r = requests.post('https://api.openreplay.com/license/validate', + json={"mid": __get_mid(), "license": get_license()}) if r.status_code != 200 or "errors" in r.json() or not r.json()["data"].get("valid"): - print("license validation failed") - print(r.text) + logger.warning("license validation failed") + logger.warning(r.text) environ["expiration"] = "-1" else: environ["expiration"] = str(r.json()["data"].get("expiration"))