Best Python code snippet using localstack_python
log.py
Source:log.py
...21 def __init__(self):22 logging.Handler.__init__(self)23 self.queue = Queue()24 self._records_lost = 025 def _put_record(self, record):26 self.format(record)27 record.msg = record.message28 record.args = None29 record.exc_info = None30 self.queue.put_nowait(record)31 def _try_to_report_lost_records(self):32 if self._records_lost:33 try:34 record = _LOGGER.makeRecord(_LOGGER.name, logging.WARNING, __file__, 0,35 'QueueHandler has lost %s log records',36 (self._records_lost,), None, 'emit')37 self._put_record(record)38 self._records_lost = 039 except Exception:40 pass41 def emit(self, record):42 try:43 self._put_record(record)44 self._try_to_report_lost_records()45 except Exception:46 self._records_lost += 147 @property48 def records_lost(self):49 return self._records_lost50class ProxyHandler(logging.Handler):51 def __init__(self, patroni_logger):52 logging.Handler.__init__(self)53 self.patroni_logger = patroni_logger54 def emit(self, record):55 self.patroni_logger.log_handler.handle(record)56class PatroniLogger(Thread):57 DEFAULT_LEVEL = 'INFO'...
messages_log.py
Source:messages_log.py
...17 chat_id=to_message.chat.id,18 message_id=to_message.message_id,19 reply_id=reply.message_id,20 )21 self._put_record(record)22 def delete_record(self, chat_id: int, message_id: int):23 """ Deletes message from log. """24 for i, record in enumerate(self._buffer):25 if record.chat_id == chat_id and record.message_id == message_id:26 self._buffer.pop(i)27 return28 raise KeyError("Record not found in log")29 def _put_record(self, record: LogRecord) -> int:30 if len(self._buffer) > self._buffer_max_size:31 self._buffer.pop(0)32 self._buffer.append(record)33 return len(self._buffer) - 134 def __iter__(self) -> Iterator[LogRecord]:...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!