Skip to content

Commit

Permalink
Merge pull request #257 from ProducerMatt/errors-in-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ProducerMatt authored Jun 27, 2023
2 parents b0939cc + 5629b71 commit 5879000
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion stam.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
import os
from sys import warnoptions

from config import database_path, enabled_modules, ALL_STAMPY_MODULES, ENVIRONMENT_TYPE

if not warnoptions: # if user hasn't passed explicit warning settings
import warnings
from typing import Literal
WARN_LEVEL: Literal['default', 'error', 'ignore', 'always', 'module', 'once']
if ENVIRONMENT_TYPE == "development":
WARN_LEVEL = 'error'
elif ENVIRONMENT_TYPE == "production":
WARN_LEVEL = 'always'
else:
raise Exception(f"Unknown environment type {ENVIRONMENT_TYPE}")

warnings.simplefilter(WARN_LEVEL) # Change the filter in this process
os.environ["PYTHONWARNINGS"] = WARN_LEVEL # Also affect subprocesses

import threading
import sys
from typing import cast

from structlog import get_logger

from config import database_path, enabled_modules, ALL_STAMPY_MODULES
from modules.module import Module
from servicemodules.discord import DiscordHandler
from servicemodules.flask import FlaskHandler
Expand Down

0 comments on commit 5879000

Please sign in to comment.