def setup_parent_logging(args, *, stream=sys.stderr): level = VERBOSITY.get(args.verbose, logging.DEBUG) handler = logging.StreamHandler() formatter = MissingFieldFormatter(LOGFORMAT) handler.setFormatter(formatter) if not args.skip_logging: logging.basicConfig(level=level, format=LOGFORMAT, handlers=[handler]) return get_logger("dramatiq", "MainProcess")
def setup_logging(args, child_id, logging_pipe): # Redirect all output to the logging pipe so that all output goes # to stderr and output is serialized so there isn't any mangling. sys.stdout = logging_pipe sys.stderr = logging_pipe level = VERBOSITY.get(args.verbose, logging.DEBUG) logging.basicConfig(level=level, format=LOGFORMAT, stream=logging_pipe) logging.getLogger("pika").setLevel(logging.CRITICAL) return get_logger("dramatiq", "%s(%s)" % (prefix, child_id))
def setup_worker_logging(args, worker_id, logging_pipe): # Redirect all output to the logging pipe so that all output goes # to stderr and output is serialized so there isn't any mangling. sys.stdout = logging_pipe sys.stderr = logging_pipe level = verbosity.get(args.verbose, logging.DEBUG) logging.basicConfig(level=level, format=logformat, stream=logging_pipe) logging.getLogger("pika").setLevel(logging.CRITICAL) return get_logger("dramatiq", "WorkerProcess(%s)" % worker_id)
def setup_logging(args, child_id, logging_pipe): # Redirect all output to the logging pipe so that all output goes # to stderr and output is serialized so there isn't any mangling. sys.stdout = logging_pipe sys.stderr = logging_pipe handler = logging.StreamHandler() formatter = MissingFieldFormatter(LOGFORMAT) handler.setFormatter(formatter) level = VERBOSITY.get(args.verbose, logging.DEBUG) if not args.skip_logging: logging.basicConfig(level=level, format=LOGFORMAT, handlers=[handler]) logging.getLogger("pika").setLevel(logging.CRITICAL) return get_logger("dramatiq", "%s(%s)" % (prefix, child_id))
def setup_parent_logging(args, *, stream=sys.stderr): level = VERBOSITY.get(args.verbose, logging.DEBUG) if not args.skip_logging: logging.basicConfig(level=level, format=LOGFORMAT, stream=stream) return get_logger("dramatiq", "MainProcess")
def setup_parent_logging(args, *, stream=sys.stderr): level = verbosity.get(args.verbose, logging.DEBUG) logging.basicConfig(level=level, format=logformat, stream=stream) return get_logger("dramatiq", "MainProcess")
def setup_worker_logging(args, worker_id, logging_pipe): level = verbosity.get(args.verbose, logging.DEBUG) logging.basicConfig(level=level, format=logformat, stream=logging_pipe) logging.getLogger("pika").setLevel(logging.ERROR) return get_logger("dramatiq", "WorkerProcess(%s)" % worker_id)
def __init__(self, max_tasks=100): self.counter_mu = Lock() self.counter = max_tasks self.signaled = False self.logger = get_logger("max_tasks_per_child.app", MaxTasksPerChild)
from dramatiq import get_logger from pymongo import MongoClient from pymongo.database import Database from pymongo.errors import ServerSelectionTimeoutError from drama.config import settings logger = get_logger(__name__) class DataBase: client: MongoClient = None db = DataBase() def create_db_connection() -> Database: logger.debug("Connecting to database for the first time") client = MongoClient(settings.MONGO_DNS) try: client.server_info() except ServerSelectionTimeoutError: raise ConnectionError(f"Could not connect to database with connection string {settings.MONGO_DNS}") db.client = client return db.client.drama