Skip to content

Commit

Permalink
Logging
Browse files Browse the repository at this point in the history
  • Loading branch information
bskjon committed Oct 23, 2024
1 parent c3eb974 commit b6ee215
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
27 changes: 26 additions & 1 deletion apps/pyMetadata/DryRun.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,40 @@
from sources.mal import Mal


log_level = os.environ.get("LOG_LEVEL") or None

configured_level = logging.INFO
if (log_level is not None):
_log_level = log_level.lower()
if (_log_level.startswith("d")):
configured_level = logging.DEBUG
elif (_log_level.startswith("e")):
configured_level = logging.ERROR
elif (_log_level.startswith("w")):
configured_level = logging.WARNING




# Konfigurer logging
logging.basicConfig(
level=logging.INFO,
level=configured_level,
format="%(asctime)s [%(levelname)s] %(message)s",
handlers=[
logging.StreamHandler(sys.stdout)
]
)
logger = logging.getLogger(__name__)

if (configured_level == logging.DEBUG):
logger.info("Logger configured with DEBUG")
elif (configured_level == logging.ERROR):
logger.info("Logger configured with ERROR")
elif (configured_level == logging.WARNING):
logger.info("Logger configured with WARNING")
else:
logger.info("Logger configured with INFO")


class DryRun():
titles: List[str] = []
Expand Down
6 changes: 2 additions & 4 deletions apps/pyMetadata/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,17 @@
events_server_database_name = os.environ.get("DATABASE_NAME_E") or "eventsV3" # "events"
events_server_username = os.environ.get("DATABASE_USERNAME") or "root"
events_server_password = os.environ.get("DATABASE_PASSWORD") or "shFZ27eL2x2NoxyEDBMfDWkvFO" #"root" // default password

log_level = os.environ.get("LOG_LEVEL") or None

configured_level = logging.INFO
if (log_level != None):
if (log_level is not None):
_log_level = log_level.lower()
if (_log_level.startswith("d")):
configured_level = logging.DEBUG
elif (_log_level.startswith("e")):
configured_level = logging.ERROR
elif (_log_level.startswith("w")):
configured_level = logging.WARNING
else:
configured_level = logging.INFO



Expand Down

0 comments on commit b6ee215

Please sign in to comment.