How to use _prepare_logger method in localstack

Best Python code snippet using localstack_python

logging.py

Source:logging.py Github

copy

Full Screen

...38 return39 self._log(context, response)40 @cached_property41 def aws_logger(self):42 return self._prepare_logger(43 logging.getLogger("localstack.request.aws"), formatter=AwsTraceLoggingFormatter44 )45 @cached_property46 def http_logger(self):47 return self._prepare_logger(48 logging.getLogger("localstack.request.http"), formatter=TraceLoggingFormatter49 )50 @cached_property51 def internal_aws_logger(self):52 return self._prepare_logger(53 logging.getLogger("localstack.request.internal.aws"), formatter=AwsTraceLoggingFormatter54 )55 @cached_property56 def internal_http_logger(self):57 return self._prepare_logger(58 logging.getLogger("localstack.request.internal.http"), formatter=TraceLoggingFormatter59 )60 # make sure loggers are loaded after logging config is loaded61 def _prepare_logger(self, logger: logging.Logger, formatter: Type):62 if logger.isEnabledFor(logging.DEBUG):63 logger.propagate = False64 handler = create_default_handler(logger.level)65 handler.setFormatter(formatter())66 logger.addHandler(handler)67 return logger68 def _log(self, context: RequestContext, response: Response):69 aws_logger = self.aws_logger70 http_logger = self.http_logger71 is_internal_call = is_internal_call_context(context.request.headers)72 if is_internal_call:73 aws_logger = self.internal_aws_logger74 http_logger = self.internal_http_logger75 if context.operation:...

Full Screen

Full Screen

common.py

Source:common.py Github

copy

Full Screen

...10 def init_adapter(self):11 pass12 def __init__(self, spark=None, init_conf=None):13 self.spark = self._prepare_spark(spark)14 self.logger = self._prepare_logger()15 if init_conf:16 self.conf = init_conf17 else:18 self.conf = self._provide_config()19 self.init_adapter()20 self._log_conf()21 @staticmethod22 def _prepare_spark(spark) -> SparkSession:23 if not spark:24 return SparkSession.builder.getOrCreate()25 else:26 return spark27 def _provide_config(self):28 self.logger.info("Reading configuration from --conf-file job option")29 conf_file = self._get_conf_file()30 if not conf_file:31 self.logger.info('No conf file was provided, setting configuration to empty dict.'32 'Please override configuration in subclass init method')33 return {}34 else:35 self.logger.info(f"Conf file was provided, reading configuration from {conf_file}")36 return self._read_config(conf_file)37 @staticmethod38 def _get_conf_file():39 p = ArgumentParser()40 p.add_argument("--conf-file", required=False, type=str)41 namespace = p.parse_known_args()[0]42 return namespace.conf_file43 def _read_config(self, conf_file) -> Dict[str, Any]:44 raw_content = "".join(self.spark.read.format("text").load(conf_file).toPandas()["value"].tolist())45 config = json.loads(raw_content)46 return config47 def _prepare_logger(self) -> Logger:48 log4j_logger = self.spark._jvm.org.apache.log4j49 return log4j_logger.LogManager.getLogger(self.__class__.__name__)50 def _log_conf(self):51 # log parameters52 self.logger.info("Launching job with configuration parameters:")53 for key, item in self.conf.items():54 self.logger.info("\t Parameter: %-30s with value => %-30s" % (key, item))55 @abstractmethod56 def launch(self):...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful